src/transformers/models/rag/modeling_tf_rag.py/TFRagTokenForGeneration/get_nll
class TFRagTokenForGeneration:    def get_nll(self, seq_logits, doc_scores, target, reduce_loss=False, epsilon=0.0, n_docs=None):
        n_docs = n_docs if n_docs is not None else self.config.n_docs
        # shift tokens left (from original Pytorch's version)

        target = tf.concat([target[:, 1:], tf.fill([target.shape[0], 1], self.config.generator.pad_token_id)], axis=1)
        rag_logprobs = self.marginalize(seq_logits, doc_scores, n_docs)
        loss = self.compute_loss(target, rag_logprobs, from_logits=True, reduce_loss=reduce_loss)

        return loss