code: def test_generic_image_transform(self):
      dataset = self.get_test_image_dataset(SampleType.TUPLE)
  
      # Check constructor asserts
      with self.assertRaises(AssertionError):
          transform = GenericImageTransform(
              split="train", transform=transforms.ToTensor()
          )
          transform = GenericImageTransform(
              split="valid", transform=None
          )
  
      # Check class constructor
      transform = GenericImageTransform(transform=None)
      PIL_sample = dataset[0]
      tensor_sample = (
          transforms.ToTensor()(PIL_sample[0]),
          PIL_sample[1],
      )
      expected_sample = {
          "input": copy.deepcopy(tensor_sample[0]),
          "target": copy.deepcopy(tensor_sample[1]),
      }
      self.transform_checks(tensor_sample, transform, expected_sample)
  
      transform = GenericImageTransform(transform=transforms.ToTensor())
      sample = dataset[0]
      expected_sample = _apply_transform_to_key_and_copy(
          {"input": sample[0], "target": sample[1]},
          transforms.ToTensor(),
          "input",
      )
      self.transform_checks(sample, transform, expected_sample)
  
      transform = GenericImageTransform(split="train")
      sample = dataset[0]
      expected_sample = _apply_transform_to_key_and_copy(
          {"input": sample[0], "target": sample[1]},
          ImagenetAugmentTransform(),
          "input",
      )
      self.transform_checks(sample, transform, expected_sample)
  
      transform = GenericImageTransform(split="test")
      sample = dataset[0]
      expected_sample = _apply_transform_to_key_and_copy(
          {"input": sample[0], "target": sample[1]},
          ImagenetNoAugmentTransform(),
          "input",
      )
      self.transform_checks(sample, transform, expected_sample)
  
      # Check from_config constructor / registry
      config = [
          {
              "name": "generic_image_transform",
              "transforms": [{"name": "ToTensor"}],
          }
      ]
      transform = build_transforms(config)
      sample = dataset[0]
      expected_sample = _apply_transform_to_key_and_copy(
          {"input": sample[0], "target": sample[1]},
          transforms.ToTensor(),
          "input",
      )
      self.transform_checks(sample, transform, expected_sample)
  
      # Check with Imagenet defaults
      config = [{"name": "generic_image_transform", "split": "train"}]
      transform = build_transforms(config)
      sample = dataset[0]
      expected_sample = _apply_transform_to_key_and_copy(
          {"input": sample[0], "target": sample[1]},
          ImagenetAugmentTransform(),
          "input",
      )
      self.transform_checks(sample, transform, expected_sample)
  
      config = [{"name": "generic_image_transform", "split": "test"}]
      transform = build_transforms(config)
      sample = dataset[0]
      expected_sample = _apply_transform_to_key_and_copy(
          {"input": sample[0], "target": sample[1]},
          ImagenetNoAugmentTransform(),
          "input",
      )
      self.transform_checks(sample, transform, expected_sample)
  
file_path: ClassyVision/test/dataset_transforms_util_test.py
imports: import copy
  import random
  import unittest
  import numpy
  import torch
  import torchvision.transforms
  from classy_vision.dataset.core.random_image_datasets import RandomImageBinaryClassDataset, SampleType
  from classy_vision.dataset.transforms import build_transforms
  from classy_vision.dataset.transforms.util import build_field_transform_default_imagenet, GenericImageTransform, ImagenetAugmentTransform, ImagenetNoAugmentTransform
label_desc: Use image node_id 6 for calling the DatasetTransformsUtilTest obj's underlying member method code with example usage: obj.test_generic_image_transform() without return types