class_docstr: Checks for overflow in gradient across parallel process
class_docstr_tok: ["Checks","for","overflow","in","gradient","across","parallel","process"]
code: def check(self, param_groups=None):
      params = []
      has_moe_params = False
      if param_groups is None:
          params = self.params
          has_moe_params = self.has_moe_params
      else:
          assert (
              param_groups is not None
          ), "self.params and param_groups both cannot be none"
  
          for group in param_groups:
              for param in group:
                  params.append(param)
                  if is_moe_param(param):
                      has_moe_params = True
  
      return self.has_overflow(params, has_moe_params=has_moe_params)
  
imports: from collections.abc import Iterable
  from deepspeed.moe.utils import is_moe_param
  import os
  import psutil
  import gc
  from math import sqrt
  from math import floor
  from bisect import bisect_left
  import torch
  from torch import inf
  from deepspeed import comm
  from deepspeed.utils import groups, logger
  from deepspeed.runtime.constants import PIPE_REPLICATED
  from numpy import prod
label_desc: Use image node_id 3 for calling the CheckOverflow obj's underlying member method code with example usage: obj.check(param_groups) and returns: self