code: def test_video_transform_factory(self):
      # Test asserts/raises.
      self.assertRaises(
          TypeError, create_video_transform, mode="val", crop_size="s"
      )
      self.assertRaises(
          AssertionError,
          create_video_transform,
          mode="val",
          crop_size=30,
          min_size=10,
      )
      self.assertRaises(
          AssertionError,
          create_video_transform,
          mode="val",
          crop_size=(30, 40),
          min_size=35,
      )
      self.assertRaises(
          AssertionError,
          create_video_transform,
          mode="val",
          remove_key="key",
      )
      self.assertRaises(
          AssertionError,
          create_video_transform,
          mode="val",
          aug_paras={"magnitude": 10},
      )
      self.assertRaises(
          NotImplementedError,
          create_video_transform,
          mode="train",
          aug_type="xyz",
      )
  
      # Test train mode.
      video = thwc_to_cthw(create_dummy_video_frames(20, 30, 40)).to(
          dtype=torch.float32
      )
      test_clip = {
          "video": video,
          "audio1": None,
          "audio2": None,
          "label": 0,
      }
  
      num_subsample = 10
      crop_size = 10
      transform = create_video_transform(
          mode="train",
          num_samples=num_subsample,
          convert_to_float=False,
          video_mean=[video.mean()] * 3,
          video_std=[video.std()] * 3,
          min_size=15,
          crop_size=crop_size,
      )
      transform_dict = create_video_transform(
          mode="train",
          video_key="video",
          remove_key=["audio1", "audio2"],
          num_samples=num_subsample,
          convert_to_float=False,
          video_mean=[video.mean()] * 3,
          video_std=[video.std()] * 3,
          min_size=15,
          crop_size=crop_size,
      )
      transform_frame = create_video_transform(
          mode="train",
          num_samples=None,
          convert_to_float=False,
          video_mean=[video.mean()] * 3,
          video_std=[video.std()] * 3,
          min_size=15,
          crop_size=crop_size,
      )
  
      video_tensor_transformed = transform(video)
      video_dict_transformed = transform_dict(test_clip)
      video_frame_transformed = transform_frame(video[:, 0:1, :, :])
      c, t, h, w = video_tensor_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      c, t, h, w = video_dict_transformed["video"].shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      self.assertFalse("audio1" in video_dict_transformed)
      self.assertFalse("audio2" in video_dict_transformed)
      c, t, h, w = video_frame_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, 1)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
  
      # Test val mode.
      video = thwc_to_cthw(create_dummy_video_frames(20, 30, 40)).to(
          dtype=torch.float32
      )
      test_clip = {"video": video, "audio": None, "label": 0}
      test_clip2 = {"video": video, "audio": None, "label": 0}
  
      num_subsample = 10
      transform = create_video_transform(
          mode="val",
          num_samples=num_subsample,
          convert_to_float=False,
          video_mean=[video.mean()] * 3,
          video_std=[video.std()] * 3,
          min_size=15,
          crop_size=crop_size,
      )
      transform_dict = create_video_transform(
          mode="val",
          video_key="video",
          num_samples=num_subsample,
          convert_to_float=False,
          video_mean=[video.mean()] * 3,
          video_std=[video.std()] * 3,
          min_size=15,
          crop_size=crop_size,
      )
      transform_comp = Compose(
          [
              ApplyTransformToKey(
                  key="video",
                  transform=Compose(
                      [
                          UniformTemporalSubsample(num_subsample),
                          NormalizeVideo(
                              [video.mean()] * 3, [video.std()] * 3
                          ),
                          ShortSideScale(size=15),
                          CenterCropVideo(crop_size),
                      ]
                  ),
              )
          ]
      )
      transform_frame = create_video_transform(
          mode="val",
          num_samples=None,
          convert_to_float=False,
          video_mean=[video.mean()] * 3,
          video_std=[video.std()] * 3,
          min_size=15,
          crop_size=crop_size,
      )
  
      video_tensor_transformed = transform(video)
      video_dict_transformed = transform_dict(test_clip)
      video_comp_transformed = transform_comp(test_clip2)
      video_frame_transformed = transform_frame(video[:, 0:1, :, :])
      self.assertTrue(
          video_tensor_transformed.equal(
              video_dict_transformed["video"]
          )
      )
      self.assertTrue(
          video_dict_transformed["video"].equal(
              video_comp_transformed["video"]
          )
      )
      torch.testing.assert_close(
          video_frame_transformed,
          video_tensor_transformed[:, 0:1, :, :],
      )
      c, t, h, w = video_dict_transformed["video"].shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      self.assertTrue("audio" in video_dict_transformed)
      c, t, h, w = video_frame_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, 1)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
  
      # Test uint8 video.
      video = thwc_to_cthw(create_dummy_video_frames(20, 30, 40))
      test_clip = {"video": video, "audio": None, "label": 0}
  
      transform_uint8 = create_video_transform(
          mode="val",
          num_samples=num_subsample,
          convert_to_float=True,
          min_size=15,
          crop_size=crop_size,
      )
      transform_float32 = create_video_transform(
          mode="val",
          num_samples=num_subsample,
          convert_to_float=False,
          min_size=15,
          crop_size=crop_size,
      )
  
      video_uint8_transformed = transform_uint8(video)
      video_float32_transformed = transform_float32(
          video.to(dtype=torch.float32) / 255.0
      )
      self.assertRaises(
          AssertionError, transform_uint8, video.to(dtype=torch.float32)
      )
      self.assertTrue(
          video_uint8_transformed.equal(video_float32_transformed)
      )
      c, t, h, w = video_uint8_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      c, t, h, w = video_float32_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
  
      # Test augmentations.
      video = thwc_to_cthw(create_dummy_video_frames(20, 30, 40))
  
      transform_randaug = create_video_transform(
          mode="train",
          num_samples=num_subsample,
          min_size=15,
          crop_size=crop_size,
          aug_type="randaug",
      )
      transform_augmix = create_video_transform(
          mode="train",
          num_samples=num_subsample,
          min_size=15,
          crop_size=crop_size,
          aug_type="augmix",
      )
      transform_randaug_paras = create_video_transform(
          mode="train",
          num_samples=num_subsample,
          min_size=15,
          crop_size=crop_size,
          aug_type="randaug",
          aug_paras={
              "magnitude": 8,
              "num_layers": 3,
              "prob": 0.7,
              "sampling_type": "uniform",
          },
      )
      transform_augmix_paras = create_video_transform(
          mode="train",
          num_samples=num_subsample,
          min_size=15,
          crop_size=crop_size,
          aug_type="augmix",
          aug_paras={
              "magnitude": 5,
              "alpha": 0.5,
              "width": 2,
              "depth": 3,
          },
      )
  
      video_randaug_transformed = transform_randaug(video)
      video_augmix_transformed = transform_augmix(video)
      video_randaug_paras_transformed = transform_randaug_paras(video)
      video_augmix_paras_transformed = transform_augmix_paras(video)
      c, t, h, w = video_randaug_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      c, t, h, w = video_augmix_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      c, t, h, w = video_randaug_paras_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
      c, t, h, w = video_augmix_paras_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
  
      # Test Inception-style cropping.
      video = thwc_to_cthw(create_dummy_video_frames(20, 30, 40))
  
      transform_inception = create_video_transform(
          mode="train",
          num_samples=num_subsample,
          min_size=15,
          crop_size=crop_size,
          random_resized_crop_paras={},
      )
  
      video_inception_transformed = transform_inception(video)
      c, t, h, w = video_inception_transformed.shape
      self.assertEqual(c, 3)
      self.assertEqual(t, num_subsample)
      self.assertEqual(h, crop_size)
      self.assertEqual(w, crop_size)
  
imports: import unittest
  from collections import Counter
  from itertools import permutations
  import numpy
  import torch
  from pytorchvideo.data.utils import thwc_to_cthw
  from pytorchvideo.transforms import ApplyTransformToKey, AugMix, create_video_transform, CutMix, MixUp, MixVideo, Normalize, OpSampler, Permute, RandAugment, RandomResizedCrop, RandomShortSideScale, ShortSideScale, UniformCropVideo, UniformTemporalSubsample
  from pytorchvideo.transforms.functional import clip_boxes_to_image, convert_to_one_hot, div_255, horizontal_flip_with_boxes, random_crop_with_boxes, random_short_side_scale_with_boxes, short_side_scale, short_side_scale_with_boxes, uniform_crop, uniform_crop_with_boxes, uniform_temporal_subsample, uniform_temporal_subsample_repeated
  from torchvision.transforms import Compose
  from torchvision.transforms._transforms_video import CenterCropVideo, NormalizeVideo, RandomCropVideo, RandomHorizontalFlipVideo
  from utils import create_dummy_video_frames, create_random_bbox
label_desc: Use image node_id 31 for calling the TestTransforms obj's underlying member method code with example usage: obj.test_video_transform_factory() without return types