code: def instantiate_ray_dataloader(
      dataset: RayDataset, batch_size: int = 1, shuffle: bool = True
  ) -> DataLoader[RayGroup]:
      r"""Initializes a dataloader to manage a ray dataset.
  
      Args:
          dataset: A ray dataset: RayDataset
          batch_size: Number of rays to sample in a batch: int
          shuffle: Whether to shuffle rays or sample then sequentially: bool
      """
  
      def collate_rays(items: List[RayGroup]) -> RayGroup:
          return items[0]
  
      if TYPE_CHECKING:
          # TODO: remove the type ignore when kornia relies on kornia 1.10
          return DataLoader(dataset)
      else:
          return DataLoader(
              dataset,
              sampler=BatchSampler(
                  RandomSampler(dataset)
                  if shuffle
                  else SequentialSampler(dataset),
                  batch_size,
                  drop_last=False,
              ),
              collate_fn=collate_rays,
          )
  
imports: from typing import TYPE_CHECKING, List, Optional, Sequence, Tuple, Union
  import torch
  from torch.utils.data import BatchSampler, DataLoader, Dataset, RandomSampler, SequentialSampler
  from typing_extensions import TypeGuard
  from kornia.core import Device, Tensor, stack
  from kornia.geometry.camera import PinholeCamera
  from kornia.io import ImageLoadType, load_image
  from kornia.nerf.core import Images, ImageTensors
  from kornia.nerf.samplers import RandomRaySampler, RaySampler, UniformRaySampler
label_desc: Use image node_id 3 for calling a global function with example usage: instantiate_ray_dataloader(dataset, batch_size, shuffle) and returns: items, DataLoader, DataLoader