code: def test_setter(self):
      e2e_data_sample = TextSpottingDataSample()
      # test gt_instances
      gt_instances_data = dict(
          bboxes=torch.rand(4, 4),
          labels=torch.rand(4),
          masks=np.random.rand(4, 2, 2),
      )
      gt_instances = InstanceData(**gt_instances_data)
      e2e_data_sample.gt_instances = gt_instances
      assert "gt_instances" in e2e_data_sample
      assert self._equal(
          e2e_data_sample.gt_instances.bboxes,
          gt_instances_data["bboxes"],
      )
      assert self._equal(
          e2e_data_sample.gt_instances.labels,
          gt_instances_data["labels"],
      )
      assert self._equal(
          e2e_data_sample.gt_instances.masks, gt_instances_data["masks"]
      )
  
      # test pred_instances
      pred_instances_data = dict(
          bboxes=torch.rand(2, 4),
          labels=torch.rand(2),
          masks=np.random.rand(2, 2, 2),
      )
      pred_instances = InstanceData(**pred_instances_data)
      e2e_data_sample.pred_instances = pred_instances
      assert "pred_instances" in e2e_data_sample
      assert self._equal(
          e2e_data_sample.pred_instances.bboxes,
          pred_instances_data["bboxes"],
      )
      assert self._equal(
          e2e_data_sample.pred_instances.labels,
          pred_instances_data["labels"],
      )
      assert self._equal(
          e2e_data_sample.pred_instances.masks,
          pred_instances_data["masks"],
      )
  
      # test type error
      with self.assertRaises(AssertionError):
          e2e_data_sample.gt_instances = torch.rand(2, 4)
      with self.assertRaises(AssertionError):
          e2e_data_sample.pred_instances = torch.rand(2, 4)
  
file_path: mmocr/tests/test_structures/test_textspotting_data_sample.py
imports: from unittest import TestCase
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from mmocr.structures import TextSpottingDataSample
label_desc: Use image node_id 3 for calling the TestTextSpottingDataSample obj's underlying member method code with example usage: obj.test_setter() without return types