code: def get_grads_for_norm(self, for_clipping=False):
      grads = []
      tensor_mp_rank = bwc_tensor_model_parallel_rank(mpu=self.mpu)
      for i, group in enumerate(self.bf16_groups):
          for j, lp in enumerate(group):
              if not for_clipping:
                  if (
                      hasattr(lp, PIPE_REPLICATED)
                      and lp.ds_pipe_replicated
                  ):
                      continue
  
                  if not (
                      tensor_mp_rank == 0
                      or is_model_parallel_parameter(lp)
                  ):
                      continue
  
              if not self.fp32_groups_has_gradients[i][j]:
                  continue
  
              grads.append(self.fp32_groups_gradients[i][j])
  
      return grads
  
imports: from collections import OrderedDict
  import torch
  import sys
  import os
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
  from deepspeed import comm
  from deepspeed.runtime.constants import PIPE_REPLICATED
  from deepspeed.runtime import ZeROOptimizer
  from packaging import version
  from deepspeed.git_version_info import version
  from deepspeed.runtime.utils import get_global_norm_of_tensors, clip_tensors_by_global_norm, DummyOptim, align_dense_tensors, all_gather_dp_groups, bwc_tensor_model_parallel_rank, is_model_parallel_parameter, see_memory_usage, graph_process
  from deepspeed.utils import link_hp_params, fragment_address
  from deepspeed.checkpoint import enable_universal_checkpoint
  from deepspeed.checkpoint.constants import DS_VERSION, PARTITION_COUNT, BASE_OPTIMIZER_STATE, SINGLE_PARTITION_OF_FP32_GROUPS, CLIP_GRAD, GROUP_PADDINGS, PARAM_SLICE_MAPPINGS
label_desc: Use image node_id 14 for calling the BF16_Optimizer obj's underlying member method code with example usage: obj.get_grads_for_norm(for_clipping) and returns: grads