code: def loss_func(loss_mask: Tensor, output_tensor: Tensor):
      """Loss function.
  
      Args:
          loss_mask (Tensor): Used to mask out some portions of the loss
          output_tensor (Tensor): The tensor with the losses
      """
      lm_loss_ = output_tensor.float()
      lm_loss = (
          torch.sum(lm_loss_.view(-1) * loss_mask.reshape(-1))
          / loss_mask.sum()
      )
  
      loss = lm_loss
      averaged_losses = average_losses_across_data_parallel_group(
          [lm_loss]
      )
  
      return loss, {"lm loss": averaged_losses[0]}
  
file_path: megatron-lm/pretrain_t5.py
imports: from functools import partial
  import torch
  from torch import Tensor
  from megatron import get_args, get_timers, print_rank_0
  from megatron.core import tensor_parallel
  from megatron.core.enums import ModelType
  from megatron.data.dataset_utils import build_train_valid_test_datasets
  from megatron.core.models.T5 import T5Model
  from megatron.training import pretrain
  from megatron.utils import average_losses_across_data_parallel_group
  from megatron.arguments import core_transformer_config_from_args
  from megatron.core.transformer.spec_utils import import_module
  from megatron.core.models.T5.t5_spec import get_t5_encoder_with_transformer_engine_block_spec, get_t5_decoder_with_transformer_engine_block_spec, get_t5_encoder_with_local_block_spec, get_t5_decoder_with_local_block_spec
label_desc: Use image node_id 3 for calling a global function with example usage: loss_func(loss_mask, output_tensor) and returns: loss,  dict