code: def test_set_gt_label(self):
      data_sample = ReIDDataSample(metainfo=dict(num_classes=5))
      method = getattr(data_sample, "set_" + "gt_label")
  
      # Test number
      method(1)
      label = data_sample.get("gt_label")
      self.assertIsInstance(label, LabelData)
      self.assertIsInstance(label.label, torch.LongTensor)
  
      # Test tensor with single number
      method(torch.tensor(2))
      label = data_sample.get("gt_label")
      self.assertIsInstance(label, LabelData)
      self.assertIsInstance(label.label, torch.LongTensor)
  
      # Test array with single number
      method(np.array(3))
      label = data_sample.get("gt_label")
      self.assertIsInstance(label, LabelData)
      self.assertIsInstance(label.label, torch.LongTensor)
  
      # Test tensor
      _label = torch.tensor([1, 2, 3])
      method(_label)
      label = data_sample.get("gt_label")
      self.assertIsInstance(label, LabelData)
      self.assertIsInstance(label.label, torch.Tensor)
      self.assertTrue(_equal(label.label, _label))
  
      # Test array
      _label = np.array([1, 2, 3])
      method(_label)
      label = data_sample.get("gt_label")
      self.assertIsInstance(label, LabelData)
      self.assertIsInstance(label.label, torch.Tensor)
      self.assertTrue(_equal(label.label, torch.from_numpy(_label)))
  
      # Test Sequence
      _label = [1, 2, 3.0]
      method(_label)
      label = data_sample.get("gt_label")
      self.assertIsInstance(label, LabelData)
      self.assertIsInstance(label.label, torch.Tensor)
      self.assertTrue(_equal(label.label, torch.tensor(_label)))
  
      # Test set num_classes
      self.assertEqual(label.num_classes, 5)
  
      # Test unavailable type
      with self.assertRaisesRegex(TypeError, "<class 'str'> is not"):
          method("hi")
  
file_path: mmdetection/tests/test_structures/test_reid_data_sample.py
imports: from unittest import TestCase
  import numpy
  import torch
  from mmengine.structures import LabelData
  from mmdet.structures import ReIDDataSample
label_desc: Use image node_id 2 for calling the TestReIDDataSample obj's underlying member method code with example usage: obj.test_set_gt_label() without return types