code: def test_add_datasample(self):
      image = self.image
      h, w, c = image.shape
  
      visualizer = KIELocalVisualizer(is_openset=True)
      visualizer.dataset_meta = dict(
          category=[
              dict(id=0, name="bg"),
              dict(id=1, name="key"),
              dict(id=2, name="value"),
              dict(id=3, name="other"),
          ]
      )
      visualizer.add_datasample("image", image, self.data_sample)
  
      with tempfile.TemporaryDirectory() as tmp_dir:
          # test out
          out_file = osp.join(tmp_dir, "out_file.jpg")
          visualizer.add_datasample(
              "image",
              image,
              self.data_sample,
              out_file=out_file,
              draw_gt=False,
              draw_pred=False,
          )
          self._assert_image_and_shape(out_file, (h, w, c))
  
          visualizer.add_datasample(
              "image", image, self.data_sample, out_file=out_file
          )
          self._assert_image_and_shape(out_file, (h * 2, w * 4, c))
  
          visualizer.add_datasample(
              "image",
              image,
              self.data_sample,
              draw_gt=False,
              out_file=out_file,
          )
          self._assert_image_and_shape(out_file, (h, w * 4, c))
  
          visualizer.add_datasample(
              "image",
              image,
              self.data_sample,
              draw_pred=False,
              out_file=out_file,
          )
          self._assert_image_and_shape(out_file, (h, w * 4, c))
  
          visualizer = KIELocalVisualizer(is_openset=False)
          visualizer.dataset_meta = dict(
              category=[
                  dict(id=0, name="bg"),
                  dict(id=1, name="key"),
                  dict(id=2, name="value"),
                  dict(id=3, name="other"),
              ]
          )
          visualizer.add_datasample(
              "image",
              image,
              self.data_sample,
              draw_pred=False,
              out_file=out_file,
          )
          self._assert_image_and_shape(out_file, (h, w * 3, c))
  
file_path: mmocr/tests/test_visualization/test_kie_visualizer.py
imports: import os.path
  import tempfile
  import unittest
  import cv2
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from mmocr.structures import KIEDataSample
  from mmocr.utils import bbox2poly
  from mmocr.visualization import KIELocalVisualizer
label_desc: Use image node_id 4 for calling the TestTextKIELocalVisualizer obj's underlying member method code with example usage: obj.test_add_datasample() without return types