code: def print_rank_last(message):
      """If distributed is initialized, print only on last rank."""
      if torch.distributed.is_initialized():
          if is_last_rank():
              print(message, flush=True)
      else:
          print(message, flush=True)
  
imports: from typing import Optional, List, Union, Tuple
  import torch
  from torch.nn.parallel import DistributedDataParallel
  from apex.multi_tensor_apply import multi_tensor_applier
  from apex.transformer import parallel_state
  from apex.transformer.enums import ModelType
  from apex.transformer.microbatches import build_num_microbatches_calculator
  from apex.transformer.pipeline_parallel._timers import _Timers
label_desc: Use image node_id 17 for calling a global function with example usage: print_rank_last(message) without return types