code: def _has_inf_or_nan(x):
      if torch.is_tensor(x):
          max_val = x.abs().max()
      else:
          max_val = x
      if max_val == float("inf"):
          return True
  
      nan_count = torch.sum(x != x)
      return nan_count > 0
  
imports: import torch
  import torch.nn
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
label_desc: Use image node_id 3 for calling the DynamicLossScaler obj's underlying member method code with example usage: obj._has_inf_or_nan(x) and returns: unknown, True