docstr: Lightning calls this inside the training loop with the data from the training dataloader
  passed in as `batch`. Loss calculation from HuggingFace's BartForConditionalGeneration.
docstr_tok: ["Lightning","calls","this","inside","the","training","loop","with","the","data","from","the","training","dataloader","passed","in","as","`","batch","`",".","Loss","calculation","from","HuggingFace","'s","BartForConditionalGeneration","."]
code: def training_step(self, batch: Tuple, batch_idx: int) -> Dict:
      """
      Lightning calls this inside the training loop with the data from the training dataloader
      passed in as `batch`. Loss calculation from HuggingFace's BartForConditionalGeneration.
      """
      input_ids, input_mask, decoder_input_ids, labels = batch
      loss = self.forward(
          input_ids=input_ids,
          attention_mask=input_mask,
          decoder_input_ids=decoder_input_ids,
          labels=labels,
      )[0]
  
      tensorboard_logs = {
          "train_loss": loss,
          "lr": self._optimizer.param_groups[0]["lr"],
      }
  
      return {"loss": loss, "log": tensorboard_logs}
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from transformers import AutoModel, BartForConditionalGeneration, EncoderDecoderModel
  from nemo.collections.common.metrics import Perplexity
  from nemo.collections.nlp.data.text2sparql import Text2SparqlDataset
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.core.classes.common import typecheck
  from nemo.core.classes.modelPT import ModelPT
  from nemo.core.neural_types import ChannelType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling the Text2SparqlModel obj's underlying member method code with example usage: obj.training_step(batch, batch_idx) and returns: dict