class_docstr: Base class to calculate hidden state loss.
  Returned dict includes a loss value and additional outputs.
class_docstr_tok: ["Base","class","to","calculate","hidden","state","loss",".","Returned","dict","includes","a","loss","value","and","additional","outputs","."]
docstr: We expect input shapes to be [S x B x H] for Sequence, Batch, Hidden sizes (due to tensor parallel support).
  We return a dictionary with dimensions [B x S x H], [B x S], [B], or [].
  
  Implement your own loss calculations. Must return "loss" key.
  loss shape - [B x S] for Batch, Sequence sizes
  batch_data - a dictionary of additional data that can be used to calculate loss
  
  Returns:
      dict: a dictionary with loss and additional outputs (must include "loss" key)
            example: {"loss": 0.0}
docstr_tok: ["We","expect","input","shapes","to","be","[","S","x","B","x","H","]","for","Sequence",",","Batch",",","Hidden","sizes","(","due","to","tensor","parallel","support",")",".","We","return","a","dictionary","with","dimensions","[","B","x","S","x","H","]",",","[","B","x","S","]",",","[","B","]",",","or","[","]",".","Implement","your","own","loss","calculations",".","Must","return","``","loss","''","key",".","loss","shape","-","[","B","x","S","]","for","Batch",",","Sequence","sizes","batch_data","-","a","dictionary","of","additional","data","that","can","be","used","to","calculate","loss","Returns",":","dict",":","a","dictionary","with","loss","and","additional","outputs","(","must","include","``","loss","''","key",")","example",":","{","``","loss","''",":","0.0","}"]
code: def _loss(self, inputs, batch_data=None):
      """
      We expect input shapes to be [S x B x H] for Sequence, Batch, Hidden sizes (due to tensor parallel support).
      We return a dictionary with dimensions [B x S x H], [B x S], [B], or [].
  
      Implement your own loss calculations. Must return "loss" key.
      loss shape - [B x S] for Batch, Sequence sizes
      batch_data - a dictionary of additional data that can be used to calculate loss
  
      Returns:
          dict: a dictionary with loss and additional outputs (must include "loss" key)
                example: {"loss": 0.0}
      """
      raise NotImplementedError(
          "Please implement loss calculations in child class"
      )
  
imports: import math
  import torch
label_desc: Use image node_id 6 for calling the MegatronBaseHiddenLoss obj's underlying member method code with example usage: obj._loss(inputs, batch_data) without return types