class_docstr: Converts the input to a specific dtype, optionally scaling the values for images or videos.
  
  .. note::
      ``ToDtype(dtype, scale=True)`` is the recommended replacement for ``ConvertImageDtype(dtype)``.
  
  Args:
      dtype (``torch.dtype`` or dict of ``TVTensor`` -> ``torch.dtype``): The dtype to convert to.
          If a ``torch.dtype`` is passed, e.g. ``torch.float32``, only images and videos will be converted
          to that dtype: this is for compatibility with :class:`~torchvision.transforms.v2.ConvertImageDtype`.
          A dict can be passed to specify per-tv_tensor conversions, e.g.
          ``dtype={tv_tensors.Image: torch.float32, tv_tensors.Mask: torch.int64, "others":None}``. The "others"
          key can be used as a catch-all for any other tv_tensor type, and ``None`` means no conversion.
      scale (bool, optional): Whether to scale the values for images or videos. See :ref:`range_and_dtype`.
          Default: ``False``.
class_docstr_tok: ["Converts","the","input","to","a","specific","dtype",",","optionally","scaling","the","values","for","images","or","videos",".","..","note",":",":","``","ToDtype","(","dtype",",","scale=True",")","``","is","the","recommended","replacement","for","``","ConvertImageDtype","(","dtype",")","``",".","Args",":","dtype","(","``","torch.dtype","``","or","dict","of","``","TVTensor","``","-",">","``","torch.dtype","``",")",":","The","dtype","to","convert","to",".","If","a","``","torch.dtype","``","is","passed",",","e.g",".","``","torch.float32","``",",","only","images","and","videos","will","be","converted","to","that","dtype",":","this","is","for","compatibility","with",":","class",":","`","~torchvision.transforms.v2.ConvertImageDtype","`",".","A","dict","can","be","passed","to","specify","per-tv_tensor","conversions",",","e.g",".","``","dtype=","{","tv_tensors.Image",":","torch.float32",",","tv_tensors.Mask",":","torch.int64",",","``","others","''",":","None","}","``",".","The","``","others","''","key","can","be","used","as","a","catch-all","for","any","other","tv_tensor","type",",","and","``","None","``","means","no","conversion",".","scale","(","bool",",","optional",")",":","Whether","to","scale","the","values","for","images","or","videos",".","See",":","ref",":","`","range_and_dtype","`",".","Default",":","``","False","``","."]
code: def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
      if isinstance(self.dtype, torch.dtype):
          # For consistency / BC with ConvertImageDtype, we only care about images or videos when dtype
          # is a simple torch.dtype
          if not is_pure_tensor(inpt) and not isinstance(
              inpt, (tv_tensors.Image, tv_tensors.Video)
          ):
              return inpt
  
          dtype: Optional[torch.dtype] = self.dtype
      elif type(inpt) in self.dtype:
          dtype = self.dtype[type(inpt)]
      elif "others" in self.dtype:
          dtype = self.dtype["others"]
      else:
          raise ValueError(
              f"No dtype was specified for type {type(inpt)}. "
              "If you only need to convert the dtype of images or videos, you can just pass e.g. dtype=torch.float32. "
              "If you're passing a dict as dtype, "
              'you can use "others" as a catch-all key '
              'e.g. dtype={tv_tensors.Mask: torch.int64, "others": None} to pass-through the rest of the inputs.'
          )
  
      supports_scaling = is_pure_tensor(inpt) or isinstance(
          inpt, (tv_tensors.Image, tv_tensors.Video)
      )
      if dtype is None:
          if self.scale and supports_scaling:
              warnings.warn(
                  "scale was set to True but no dtype was specified for images or videos: no scaling will be done."
              )
          return inpt
  
      return self._call_kernel(
          F.to_dtype, inpt, dtype=dtype, scale=self.scale
      )
  
imports: import warnings
  from typing import Any, Callable, cast, Dict, List, Optional, Sequence, Type, Union
  import PIL.Image
  import torch
  from torch.utils._pytree import tree_flatten, tree_unflatten
  from torchvision import transforms, tv_tensors
  from torchvision.transforms.v2 import functional, Transform
  from ._utils import _parse_labels_getter, _setup_number_or_seq, _setup_size, get_bounding_boxes, has_any, is_pure_tensor
label_desc: Use image node_id 2 for calling the ToDtype obj's underlying member method code with example usage: obj._transform(inpt, params) and returns: self, inpt, inpt