code: def test_random_apply(device):
      tensor, _ = _create_data(26, 34, device=device)
      tensor = tensor.to(dtype=torch.float32) / 255.0
  
      transforms = T.RandomApply(
          [
              T.RandomHorizontalFlip(),
              T.ColorJitter(),
          ],
          p=0.4,
      )
      s_transforms = T.RandomApply(
          torch.nn.ModuleList(
              [
                  T.RandomHorizontalFlip(),
                  T.ColorJitter(),
              ]
          ),
          p=0.4,
      )
  
      scripted_fn = torch.jit.script(s_transforms)
      torch.manual_seed(12)
      transformed_tensor = transforms(tensor)
      torch.manual_seed(12)
      transformed_tensor_script = scripted_fn(tensor)
      assert_equal(
          transformed_tensor,
          transformed_tensor_script,
          msg=f"{transforms}",
      )
  
      if device == "cpu":
          # Can't check this twice, otherwise
          # "Can't redefine method: forward on class: __torch__.torchvision.transforms.transforms.RandomApply"
          transforms = T.RandomApply(
              [
                  T.ColorJitter(),
              ],
              p=0.3,
          )
          with pytest.raises(
              RuntimeError,
              match="Module 'RandomApply' has no attribute 'transforms'",
          ):
              torch.jit.script(transforms)
  
imports: import os
  import sys
  import numpy
  import PIL.Image
  import pytest
  import torch
  from common_utils import _assert_approx_equal_tensor_to_pil, _assert_equal_tensor_to_pil, _create_data, _create_data_batch, assert_equal, cpu_and_cuda, float_dtypes, get_tmp_dir, int_dtypes
  from torchvision import transforms
  from torchvision.transforms import functional, InterpolationMode
  from torchvision.transforms.autoaugment import _apply_op
label_desc: Use image node_id 42 for calling a global function with example usage: test_random_apply(device) without return types