code: def calc_params_l2_norm(model: torch.nn.Module, bf16: bool):
      """Calculate l2 norm of parameters"""
      # args = get_args()
      if not isinstance(model, list):
          model = [model]
      # Remove duplicate params.
      params_data = []
      for model_ in model:
          for param in model_.parameters():
              is_not_shared = param_is_not_shared(param)
              is_not_tp_duplicate = (
                  parallel_state.param_is_not_tensor_parallel_duplicate(
                      param
                  )
              )
              if is_not_shared and is_not_tp_duplicate:
                  if bf16:
                      params_data.append(param.data.float())
                  else:
                      params_data.append(param.data)
      # Calculate norm
      dummy_overflow_buf = torch.cuda.IntTensor([0])
      norm, _ = multi_tensor_applier(
          amp_C.multi_tensor_l2norm,
          dummy_overflow_buf,
          [params_data],
          False,  # no per-parameter norm
      )
      norm_2 = norm * norm
      # Sum across all model-parallel GPUs.
      torch.distributed.all_reduce(
          norm_2,
          op=torch.distributed.ReduceOp.SUM,
          group=parallel_state.get_model_parallel_group(),
      )
      return norm_2.item() ** 0.5
  
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 21 for calling a global function with example usage: calc_params_l2_norm(model, bf16) and returns: unknown