code: def dtype_safe(x: Any) -> Union[torch.dtype, Type]:
      """
      Exception-safe getter for ``dtype`` attribute
  
      Args:
          x: any object
  
      Returns:
          ``x.dtype`` if attribute exists, type of x otherwise
      """
      return getattr(x, "dtype", type(x))
  
file_path: opacus/opacus/data_loader.py
imports: import logging
  from functools import partial
  from typing import Any, List, Optional, Sequence, Tuple, Type, Union
  import torch
  from opacus.utils.uniform_sampler import DistributedUniformWithReplacementSampler, UniformWithReplacementSampler
  from torch.utils.data import BatchSampler, DataLoader, Dataset, IterableDataset, Sampler
  from torch.utils.data._utils.collate import default_collate
  from torch.utils.data.dataloader import _collate_fn_t
label_desc: Use image node_id 4 for calling a global function with example usage: dtype_safe(x) and returns: getattr