code: def test_packrecogtinput(self):
      datainfo = dict(
          img=np.random.random((10, 10)),
          img_shape=(10, 10),
          ori_shape=(10, 10),
          pad_shape=(10, 10),
          scale_factor=(1, 1),
          img_path="tmp/tmp.jpg",
          flip=True,
          flip_direction="left",
          gt_bboxes=np.array([[0, 0, 10, 10]]),
          gt_labels=np.array([0]),
          gt_polygons=[[0, 0, 0, 10, 10, 10, 10, 0]],
          gt_texts=["mmocr"],
      )
      with self.assertRaises(KeyError):
          transform = PackTextRecogInputs(meta_keys=("tmp",))
          transform(copy.deepcopy(datainfo))
      transform = PackTextRecogInputs()
      results = 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.assertEqual(data_sample.gt_text.item, "mmocr")
      self.assertIn("img_path", data_sample)
      self.assertIn("valid_ratio", data_sample)
      self.assertIn("pad_shape", data_sample)
  
      # test non-contiugous img
      nc_datainfo = copy.deepcopy(datainfo)
      nc_datainfo["img"] = nc_datainfo["img"].transpose(1, 0)
      results = transform(nc_datainfo)
      self.assertIn("inputs", results)
      self.assertEqual(results["inputs"].shape, torch.Size([1, 10, 10]))
  
      transform = PackTextRecogInputs(meta_keys=("img_path",))
      results = transform(copy.deepcopy(datainfo))
      self.assertIn("inputs", results)
      self.assertIn("data_samples", results)
      data_sample = results["data_samples"]
      self.assertEqual(data_sample.gt_text.item, "mmocr")
      self.assertIn("img_path", data_sample)
      self.assertNotIn("valid_ratio", data_sample)
      self.assertNotIn("pad_shape", data_sample)
  
      datainfo = dict(img_shape=(10, 10))
      transform = PackTextRecogInputs(meta_keys=("img_shape",))
      results = transform(copy.deepcopy(datainfo))
      self.assertNotIn("inputs", results)
      data_sample = results["data_samples"]
      self.assertNotIn("item", data_sample.gt_text)
  
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 1 for calling the TestPackTextRecogInputs obj's underlying member method code with example usage: obj.test_packrecogtinput() without return types