code: def cross_entropy_loss_func(labels, output_tensor):
      logits = output_tensor
  
      # Cross-entropy loss.
      loss_func = torch.nn.CrossEntropyLoss()
      loss = loss_func(logits.contiguous().float(), labels)
  
      # Reduce loss for logging.
      averaged_loss = average_losses_across_data_parallel_group([loss])
  
      return loss, {"lm loss": averaged_loss[0]}
  
imports: from functools import partial
  import sys
  import torch
  from megatron import get_args, get_num_microbatches
  from megatron import print_rank_0
  from megatron import get_timers
  from megatron.core import mpu
  from megatron.core.enums import ModelType
  from megatron.checkpointing import load_checkpoint
  from megatron.checkpointing import save_checkpoint
  from megatron.training import evaluate_and_print_results
  from megatron.training import setup_model_and_optimizer
  from megatron.training import train_step
  from megatron.training import training_log
  from megatron.utils import average_losses_across_data_parallel_group
  from megatron.utils import calc_params_l2_norm
  from megatron.utils import check_adlr_autoresume_termination
label_desc: Use image node_id 2 for calling a global function with example usage: cross_entropy_loss_func(labels, output_tensor) and returns: loss,  dict