code: def test_transform(self):
      datainfo = dict(
          img=np.random.random((10, 10)),
          img_shape=(10, 10),
          ori_shape=(10, 10),
          scale_factor=(1, 1),
          img_path="tmp/tmp.jpg",
          gt_bboxes=np.array(
              [[0, 0, 10, 10], [5, 5, 15, 15]], dtype=np.float32
          ),
          gt_bboxes_labels=np.array([0, 0], np.int64),
          gt_edges_labels=np.array([[0, 0], [0, 0]], np.int64),
          gt_texts=["text1", "text2"],
      )
  
      with self.assertRaises(KeyError):
          transform = PackKIEInputs(meta_keys=("tmp",))
          transform(copy.deepcopy(datainfo))
  
      results = self.transform(copy.deepcopy(datainfo))
      self.assertIn("inputs", results)
      self.assertTupleEqual(tuple(results["inputs"].shape), (1, 10, 10))
      self.assertIn("data_samples", results)
      data_sample = results["data_samples"]
      self.assertIsInstance(
          data_sample.gt_instances.bboxes, torch.Tensor
      )
      self.assertEqual(
          data_sample.gt_instances.bboxes.dtype, torch.float32
      )
      self.assertEqual(
          data_sample.gt_instances.labels.dtype, torch.int64
      )
      self.assertEqual(
          data_sample.gt_instances.edge_labels.dtype, torch.int64
      )
      self.assertIsInstance(data_sample.gt_instances.texts, list)
  
      # test non-contiugous img
      nc_datainfo = copy.deepcopy(datainfo)
      nc_datainfo["img"] = nc_datainfo["img"].transpose(1, 0)
      results = self.transform(nc_datainfo)
      self.assertIn("inputs", results)
      self.assertEqual(results["inputs"].shape, torch.Size([1, 10, 10]))
  
      transform = PackKIEInputs(meta_keys=("img_path",))
      results = transform(copy.deepcopy(datainfo))
      self.assertIn("inputs", results)
      self.assertIn("data_samples", results)
  
      data_sample = results["data_samples"]
      self.assertIn("bboxes", data_sample.gt_instances)
      self.assertIn("img_path", data_sample)
  
      datainfo.pop("img")
      results = self.transform(copy.deepcopy(datainfo))
      self.assertIn("inputs", results)
      self.assertEqual(results["inputs"].shape, torch.Size((0, 0, 0)))
  
file_path: mmocr/tests/test_datasets/test_transforms/test_formatting.py
imports: import copy
  from unittest import TestCase
  import numpy
  import torch
  from mmocr.datasets.transforms import PackKIEInputs, PackTextDetInputs, PackTextRecogInputs
label_desc: Use image node_id 2 for calling the TestPackKIEInputs obj's underlying member method code with example usage: obj.test_transform() without return types