docstr: This helper function applies the transform to the sample
  and verifies that the output is the expected_sample. The
  sole purpose is to make sure copying / random seed / checking
  all of the fields in the sample happens correctly.
docstr_tok: ["This","helper","function","applies","the","transform","to","the","sample","and","verifies","that","the","output","is","the","expected_sample",".","The","sole","purpose","is","to","make","sure","copying","\/","random","seed","\/","checking","all","of","the","fields","in","the","sample","happens","correctly","."]
code: def transform_checks(
      self, sample, transform, expected_sample, seed=0
  ):
      """
      This helper function applies the transform to the sample
      and verifies that the output is the expected_sample. The
      sole purpose is to make sure copying / random seed / checking
      all of the fields in the sample happens correctly.
      """
      transformed_sample = copy.deepcopy(sample)
      torch.manual_seed(seed)
      numpy.random.seed(seed)
      random.seed(seed)
      transformed_sample = transform(transformed_sample)
  
      if isinstance(expected_sample, (tuple, list)):
          for transformed, exp in zip(
              transformed_sample, expected_sample
          ):
              if torch.is_tensor(exp):
                  self.assertTrue(torch.allclose(transformed, exp))
  
      if isinstance(expected_sample, dict):
          for key, exp_val in expected_sample.items():
              self.assertTrue(key in transformed_sample)
              if torch.is_tensor(exp_val):
                  self.assertTrue(
                      torch.allclose(transformed_sample[key], exp_val)
                  )
              elif isinstance(exp_val, float):
                  self.assertAlmostEqual(
                      transformed_sample[key], exp_val
                  )
              else:
                  self.assertEqual(transformed_sample[key], exp_val)
  
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 2 for calling the DatasetTransformsUtilTest obj's underlying member method code with example usage: obj.transform_checks(sample, transform, expected_sample, seed) without return types