code: def unwrap_model(model, module_instances=(DistributedDataParallel,)):
      return_list = True
      if not isinstance(model, list):
          model = [model]
          return_list = False
      unwrapped_model = []
      for model_module in model:
          while isinstance(model_module, module_instances):
              model_module = model_module.module
          unwrapped_model.append(model_module)
      if not return_list:
          return unwrapped_model[0]
      return unwrapped_model
  
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 19 for calling a global function with example usage: unwrap_model(model, module_instances) and returns: unwrapped_model, unwrapped_model