class_docstr: A custom dataset class for loading images from a directory structure.
  This class inherits from torch.utils.data.Dataset.
class_docstr_tok: ["A","custom","dataset","class","for","loading","images","from","a","directory","structure",".","This","class","inherits","from","torch.utils.data.Dataset","."]
code: def __getitem__(self, index: int) -> Tuple[torch.Tensor, int]:
      if index >= len(self):
          raise IndexError(f"Index {index} ot of bound {len(self)}")
  
      sample_path, category = self._samples[index]
  
      image = Image.open(sample_path)
  
      if self._transform is not None:
          image = self._transform(image)
  
      return image, category
  
file_path: NeMo/nemo/collections/multimodal/data/nsfw/nsfw_dataset.py
imports: import pathlib
  from typing import Callable, List, Optional, Tuple
  import torch
  from omegaconf.dictconfig import DictConfig
  from PIL import Image
  from nemo.collections.multimodal.data.clip.augmentations.augmentations import image_transform
label_desc: Use image node_id 2 for calling the DirectoryBasedDataset obj's underlying member method code with example usage: obj.__getitem__(index) and returns: image,  category