How the dataloder works?

i’m trying to design a new decoder of seq2seq model, to implement a new relative position encoding loss.
during the process, it is confusing me that how to add an additional target dataset into the ‘batch’ parameter, specifically, I need to set a new sub-feature in the ‘batch’ object.
but when I read the code in I found it confused me in the definition of class ‘NMTLossCompute’ and its baseclass ‘LossComputeBase’.
how can I found the definition of the parameter ‘batch’ in function ‘_make_shard_state’ and ‘_compute_loss’? It seems to correlated with the work style of dataloader.
Can anyone give a simple trace guiding of the stream of the ‘batch’?
thanks verymuch if anyone can give a little advising. ONMT is the best project i’ve ever seen, to carry on NMT task, simple enough to understand, and, powerfull enough to do my experiment.

You may want to have a look at this PR which was not merged for now but is quite close to what you seem to be interested in.
Basic idea is to add some Field in the dataset base class, which will then be available to use from your batches. Changes are quite straightforward in the PR I believe.