code: def build_dataset(
      model_cfg: DictConfig, consumed_samples: int, is_train: bool
  ):
      """
      Builds and returns a DirectoryBasedDataset instance.
      """
      img_fn = image_transform(
          (model_cfg.vision.img_h, model_cfg.vision.img_w),
          is_train=False,
          mean=model_cfg.vision.image_mean,
          std=model_cfg.vision.image_std,
          resize_longest_max=True,
      )
  
      if is_train:
          path = model_cfg.data.train.dataset_path
      else:
          path = model_cfg.data.validation.dataset_path
  
      return DirectoryBasedDataset(path, transform=img_fn)
  
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 1 for calling a global function with example usage: build_dataset(model_cfg, consumed_samples, is_train) and returns: DirectoryBasedDataset