code: def test_imagelist_padding_tracing(self):
      # test that the trace does not contain hard-coded constant sizes
      def to_imagelist(tensors: Sequence[torch.Tensor]):
          image_list = ImageList.from_tensors(tensors, 4)
          return image_list.tensor, image_list.image_sizes
  
      def _tensor(*shape):
          return torch.ones(shape, dtype=torch.float32)
  
      # test CHW (inputs needs padding vs. no padding)
      for shape in [(3, 10, 10), (3, 12, 12)]:
          func = torch.jit.trace(to_imagelist, ([_tensor(*shape)],))
          tensor, image_sizes = func([_tensor(3, 15, 20)])
          self.assertEqual(tensor.shape, (1, 3, 16, 20), tensor.shape)
          self.assertEqual(
              image_sizes[0].tolist(), [15, 20], image_sizes[0]
          )
  
      # test HW
      func = torch.jit.trace(to_imagelist, ([_tensor(10, 10)],))
      tensor, image_sizes = func([_tensor(15, 20)])
      self.assertEqual(tensor.shape, (1, 16, 20), tensor.shape)
      self.assertEqual(
          image_sizes[0].tolist(), [15, 20], image_sizes[0]
      )
  
      # test 2x CHW
      func = torch.jit.trace(
          to_imagelist,
          ([_tensor(3, 16, 10), _tensor(3, 13, 11)],),
      )
      tensor, image_sizes = func(
          [_tensor(3, 25, 20), _tensor(3, 10, 10)]
      )
      self.assertEqual(tensor.shape, (2, 3, 28, 20), tensor.shape)
      self.assertEqual(
          image_sizes[0].tolist(), [25, 20], image_sizes[0]
      )
      self.assertEqual(
          image_sizes[1].tolist(), [10, 10], image_sizes[1]
      )
  
file_path: detectron2/tests/structures/test_imagelist.py
imports: import unittest
  from typing import List, Sequence, Tuple
  import torch
  from detectron2.structures import ImageList
label_desc: Use image node_id 1 for calling the TestImageList obj's underlying member method code with example usage: obj.test_imagelist_padding_tracing() and returns: image_list,  image_list, torch