Best way to pass auxiliary arrays to Knet loss function

Julia beginner here, so I apologize if this is an obvious question. I’m implementing a model using Knet, and I’m writing a loss function that includes a penalty term that relies on information that is provided from outside the model. I’m not sure the best way to provide this information to the loss function.

Suppose that I have the normal arrays x and y that contain the training data and target data, along with two auxiliary arrays a and b that contain the extra information. To be concrete, suppose they have the following dimensions, where N is the number of samples (images, in this case):

x = Array{Float32}(undef, (128, 128, 1, N))
y = Array{Float32}(undef, (128, 128, 1, N))
a = Array{UInt16}(undef, (128^2, N))
b = Array{Array{Float32}}(undef, N)

I’m running the model like this:
progress!(adam(network, ncycle(x,n_epochs)))

Because I don’t call the loss function directly, I’m not sure how to pass the arguments to it.

The best thing I could think of was to modify the existing minibatch() function so that instead of returning (x[i], y[i]) pairs, it would return something like (x[i], (y[i], a[i], b[i])), and then the loss function would unpack the second term in the outer tuple to get the arrays.

This seems like it would work, but I’d like to know if there’s a way to do it that doesn’t require modifying existing functions provided by Knet.

Thanks for any tips you could give me!