code: def test_pad(device, dt, pad, config):
      script_fn = torch.jit.script(F.pad)
      tensor, pil_img = _create_data(7, 8, device=device)
      batch_tensors = _create_data_batch(
          16, 18, num_samples=4, device=device
      )
  
      if dt == torch.float16 and device == "cpu":
          # skip float16 on CPU case
          return
  
      if dt is not None:
          # This is a trivial cast to float of uint8 data to test all cases
          tensor = tensor.to(dt)
          batch_tensors = batch_tensors.to(dt)
  
      pad_tensor = F_t.pad(tensor, pad, **config)
      pad_pil_img = F_pil.pad(pil_img, pad, **config)
  
      pad_tensor_8b = pad_tensor
      # we need to cast to uint8 to compare with PIL image
      if pad_tensor_8b.dtype != torch.uint8:
          pad_tensor_8b = pad_tensor_8b.to(torch.uint8)
  
      _assert_equal_tensor_to_pil(
          pad_tensor_8b, pad_pil_img, msg=f"{pad}, {config}"
      )
  
      if isinstance(pad, int):
          script_pad = [
              pad,
          ]
      else:
          script_pad = pad
      pad_tensor_script = script_fn(tensor, script_pad, **config)
      assert_equal(
          pad_tensor, pad_tensor_script, msg=f"{pad}, {config}"
      )
  
      _test_fn_on_batch(
          batch_tensors, F.pad, padding=script_pad, **config
      )
  
imports: import colorsys
  import itertools
  import math
  import os
  from functools import partial
  from typing import Sequence
  import numpy
  import PIL.Image
  import pytest
  import torch
  import torchvision.transforms
  import torchvision.transforms._functional_pil
  import torchvision.transforms._functional_tensor
  import torchvision.transforms.functional
  from common_utils import _assert_approx_equal_tensor_to_pil, _assert_equal_tensor_to_pil, _create_data, _create_data_batch, _test_fn_on_batch, assert_equal, cpu_and_cuda, needs_cuda
  from torchvision.transforms import InterpolationMode
label_desc: Use image node_id 26 for calling a global function with example usage: test_pad(device, dt, pad, config) without return types