code: def test_add_datasample(self):
      image = self.image
      h, w, c = image.shape
  
      visualizer = TextSpottingLocalVisualizer()
      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 * 2, 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 * 2, 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 * 2, c))
          bboxes = self.data_sample.pred_instances.get("bboxes")
          bboxes = bboxes.tolist()
          polys = [bbox2poly(bbox) for bbox in bboxes]
          self.data_sample.pred_instances.polygons = polys
          visualizer.add_datasample(
              "image",
              image,
              self.data_sample,
              draw_gt=False,
              out_file=out_file,
          )
          self._assert_image_and_shape(out_file, (h, w * 2, c))
  
file_path: mmocr/tests/test_visualization/test_textspotting_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 TextDetDataSample
  from mmocr.utils import bbox2poly
  from mmocr.visualization import TextSpottingLocalVisualizer
label_desc: Use image node_id 4 for calling the TestTextSpottingLocalVisualizer obj's underlying member method code with example usage: obj.test_add_datasample() without return types