code: def post_language_model_processing(
      lm_output,
      labels,
      logit_weights,
      get_key_value,
      parallel_output,
      forward_method_parallel_output,
      fp16_lm_cross_entropy,
      return_logits=False,
      sequence_parallel=False,
      gradient_accumulation_fusion=False,
  ):
      if get_key_value:
          lm_output, presents = lm_output
  
      # Output. Format is [s b h]
      if forward_method_parallel_output is not None:
          parallel_output = forward_method_parallel_output
      async_tensor_model_parallel_allreduce = (
          parallel_state.get_tensor_model_parallel_world_size() > 1
          and not sequence_parallel
      )
      output = parallel_lm_logits(
          lm_output,
          logit_weights,
          parallel_output,
          sequence_parallel=sequence_parallel,
          gradient_accumulation_fusion=gradient_accumulation_fusion,
          async_tensor_model_parallel_allreduce=async_tensor_model_parallel_allreduce,
      )
  
      if get_key_value:
          output = [output, presents]
  
      if labels is None:
          # [s b h] -> [b s h]
          return output.transpose(0, 1).contiguous()
      else:
          # [b s] -> [s b]
          labels = labels.transpose(0, 1).contiguous()
  
          if fp16_lm_cross_entropy:
              assert output.dtype == torch.half
              loss = tensor_parallel.vocab_parallel_cross_entropy(
                  output, labels
              )
          else:
              loss = tensor_parallel.vocab_parallel_cross_entropy(
                  output.float(), labels
              )
  
          # [s b] -> [b, s]
          loss = loss.transpose(0, 1).contiguous()
  
          if return_logits:
              return loss, output
          else:
              return loss
  
file_path: NeMo/nemo/collections/nlp/models/language_modeling/megatron/gpt_model.py
imports: import torch
  from nemo.collections.nlp.modules.common.megatron.language_model import get_language_model
  from nemo.collections.nlp.modules.common.megatron.module import MegatronModule
  from nemo.collections.nlp.modules.common.megatron.utils import ApexGuardDefaults, init_method_normal, parallel_lm_logits, scaled_init_method_normal
label_desc: Use image node_id 1 for calling a global function with example usage: post_language_model_processing(lm_output, labels, logit_weights, get_key_value, parallel_output, forward_method_parallel_output, fp16_lm_cross_entropy, return_logits, sequence_parallel, gradient_accumulation_fusion) and returns: output, loss,  output, loss