class_docstr: Apply a `TorchVision transform <https://pytorch.org/vision/stable/transforms.html>`_
  to image columns.
  
  Examples:
  
      Torch models expect inputs of shape :math:`(B, C, H, W)` in the range
      :math:`[0.0, 1.0]`. To convert images to this format, add ``ToTensor`` to your
      preprocessing pipeline.
  
      .. testcode::
  
          from torchvision import transforms
  
          import ray
          from ray.data.preprocessors import TorchVisionPreprocessor
  
          transform = transforms.Compose([
              transforms.ToTensor(),
              transforms.Resize((224, 224)),
          ])
          preprocessor = TorchVisionPreprocessor(["image"], transform=transform)
  
          dataset = ray.data.read_images("s3://anonymous@air-example-data-2/imagenet-sample-images")
          dataset = preprocessor.transform(dataset)
  
  
      For better performance, set ``batched`` to ``True`` and replace ``ToTensor``
      with a batch-supporting ``Lambda``.
  
      .. testcode::
  
          import numpy as np
          import torch
  
          def to_tensor(batch: np.ndarray) -> torch.Tensor:
              tensor = torch.as_tensor(batch, dtype=torch.float)
              # (B, H, W, C) -> (B, C, H, W)
              tensor = tensor.permute(0, 3, 1, 2).contiguous()
              # [0., 255.] -> [0., 1.]
              tensor = tensor.div(255)
              return tensor
  
          transform = transforms.Compose([
              transforms.Lambda(to_tensor),
              transforms.Resize((224, 224))
          ])
          preprocessor = TorchVisionPreprocessor(["image"], transform=transform, batched=True)
  
          dataset = ray.data.read_images("s3://anonymous@air-example-data-2/imagenet-sample-images")
          dataset = preprocessor.transform(dataset)
  
  Args:
      columns: The columns to apply the TorchVision transform to.
      transform: The TorchVision transform you want to apply. This transform should
          accept a ``np.ndarray`` or ``torch.Tensor`` as input and return a
          ``torch.Tensor`` as output.
      output_columns: The output name for each input column. If not specified, this
          defaults to the same set of columns as the columns.
      batched: If ``True``, apply ``transform`` to batches of shape
          :math:`(B, H, W, C)`. Otherwise, apply ``transform`` to individual images.
code: def __repr__(self) -> str:
      return (
          f"{self.__class__.__name__}("
          f"columns={self._columns}, "
          f"output_columns={self._output_columns}, "
          f"transform={self._torchvision_transform!r})"
      )
  
file_path: ray/python/ray/data/preprocessors/torch.py
imports: from typing import TYPE_CHECKING, Callable, Dict, List, Mapping, Optional, Union
  import numpy
  from ray.air.util.data_batch_conversion import BatchFormat
  from ray.air.util.tensor_extensions.utils import _create_possibly_ragged_ndarray
  from ray.data.preprocessor import Preprocessor
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 2 for calling the TorchVisionPreprocessor obj's underlying member method code with example usage: obj.__repr__() and returns: self, str, self, str, self, str, self, str