code: def get_grad_norm_(parameters, norm_type=2.0):
      if isinstance(parameters, torch.Tensor):
          parameters = [parameters]
      parameters = [p for p in parameters if p.grad is not None]
      norm_type = float(norm_type)
      if len(parameters) == 0:
          return torch.tensor(0.0)
      device = parameters[0].grad.device
      if norm_type == "inf":
          total_norm = max(
              p.grad.detach().abs().max().to(device) for p in parameters
          )
      else:
          total_norm = torch.norm(
              torch.stack(
                  [
                      torch.norm(p.grad.detach(), norm_type).to(device)
                      for p in parameters
                  ]
              ),
              norm_type,
          )
      return total_norm
  
file_path: SlowFast/slowfast/models/optimizer.py
imports: import torch
  import slowfast.utils.lr_policy
label_desc: Use image node_id 5 for calling a global function with example usage: get_grad_norm_(parameters, norm_type) and returns: total_norm, torch