code: def test_imagenet_dataset_val(
      config_file_path: str,
      mock_dataset_class: Type[MockImageNetDataset],
  ) -> None:
      """Test for ImageNet dataset and its variants.
  
      This test mocks `__init__` and `read_image_pil` functions to test the `__getitem__`
      function (that includes data transforms). Training and validation datasets are
      wrapped inside the respective data loaders to test the collate function used by
      dataset.
  
      Args:
        config_file_path: Path to a dummy config for initializing the dataset.
        mock_dataset_class: The class type for ImageNet or one of its shifts.
      """
      opts = get_config(config_file=config_file_path)
  
      valid_imagenet_dataset = mock_dataset_class(
          opts, is_training=False, is_evaluation=False
      )
  
      val_sampler = build_sampler(
          opts,
          n_data_samples=len(valid_imagenet_dataset),
          is_training=False,
      )
  
      val_loader = CVNetsDataLoader(
          dataset=valid_imagenet_dataset,
          batch_sampler=val_sampler,
          batch_size=1,
          num_workers=0,
      )
  
      for batch in val_loader:
          assert batch.keys() == {"samples", "targets", "sample_id"}
          # values from config file
          assert [*batch["samples"].shape[2:]] == [224, 224]
          assert batch["samples"].dim() == 4, (
              "Expecting input images in "
              "[batch, image_channels, height, width] format"
          )
          assert (
              batch["targets"].dim() == 1
          ), "Expecting labels in [batch, ] format"
          assert (
              batch["sample_id"].dim() == 1
          ), "Expecting sample_id's in [batch, ] format"
  
imports: from typing import Type
  import pytest
  from data.loader.dataloader import CVNetsDataLoader
  from data.sampler import build_sampler
  from tests.configs import get_config
  from tests.data.datasets.classification.mock_imagenet import MockImageNetADataset, MockImageNetDataset, MockImageNetRDataset, MockImageNetSketchDataset
label_desc: Use image node_id 2 for calling a global function with example usage: test_imagenet_dataset_val(config_file_path, mock_dataset_class) without return types