code: def build_torch_dataset(
      root_dir,
      batch_size,
      shuffle=False,
      num_workers=None,
      transform=None,
  ):
      if num_workers is None:
          num_workers = os.cpu_count()
  
      data = torchvision.datasets.ImageFolder(
          root_dir, transform=transform
      )
      data_loader = torch.utils.data.DataLoader(
          data,
          batch_size=batch_size,
          shuffle=shuffle,
          num_workers=num_workers,
          persistent_workers=True,
      )
      return data_loader
  
imports: import ray
  import torch
  import torchvision
  from torchvision.transforms.functional import pil_to_tensor
  import os
  import tensorflow
  import numpy
  from PIL import Image
  from typing import TYPE_CHECKING, Iterator, Callable, Any
  import pandas
  from benchmark import Benchmark
  import streaming
  from streaming import LocalDataset, StreamingDataset
  from ray.data._internal.delegating_block_builder import DelegatingBlockBuilder
label_desc: Use image node_id 1 for calling a global function with example usage: build_torch_dataset(root_dir, batch_size, shuffle, num_workers, transform) and returns: data_loader