code: def get_main_grads_for_grad_norm(self):
      # Filter parameters based on:
      #   - grad should not be none
      #   - parameter should not be shared
      #   - should not be a replica due to tensor model parallelism
      params = self.get_parameters()
      grads_for_norm = []
      for param in params:
          grad = param.grad
          grad_not_none = grad is not None
          is_not_shared = param_is_not_shared(param)
          is_not_tp_duplicate = (
              tensor_parallel.param_is_not_tensor_parallel_duplicate(
                  param
              )
          )
          if grad_not_none and is_not_shared and is_not_tp_duplicate:
              grads_for_norm.append(grad)
  
      return grads_for_norm
  
imports: from abc import ABC
  from abc import abstractmethod
  from apex.multi_tensor_apply import multi_tensor_applier
  import amp_C
  import torch
  from megatron import get_timers
  from megatron import print_rank_0
  from megatron.core import mpu, tensor_parallel
  from megatron.model import Float16Module
  from megatron.model.module import param_is_not_shared
  from .clip_grads import clip_grad_norm_fp32, count_zeros_fp32
label_desc: Use image node_id 3 for calling the MegatronOptimizer obj's underlying member method code with example usage: obj.get_main_grads_for_grad_norm() and returns: grads_for_norm