docstr: Check if the chunk has inf or nan values on CUDA.
docstr_tok: ["Check","if","the","chunk","has","inf","or","nan","values","on","CUDA","."]
code: def has_inf_or_nan(self) -> bool:
      """Check if the chunk has inf or nan values on CUDA."""
      if self.is_gathered:
          valid_tensor = self.cuda_global_chunk[: self.utilized_size]
      else:
          assert self.cuda_shard is not None  # only check on CUDA
          valid_tensor = self.cuda_shard[: self.valid_end]
  
      return (
          torch.isinf(valid_tensor).any().item()
          | torch.isnan(valid_tensor).any().item()
      )
  
imports: from dataclasses import dataclass
  from enum import Enum
  from typing import Dict, List, Optional
  import torch
  import torch.distributed
  from torch.distributed import ProcessGroup
  from colossalai.utils import get_current_device
  from colossalai.utils.device import IS_NPU_AVAILABLE
label_desc: Use image node_id 9 for calling the Chunk obj's underlying member method code with example usage: obj.has_inf_or_nan() and returns: unknown