code: def test_convert_box_type(self):
      @register_box("A")
      class A(ToyBaseBoxes):
          pass
  
      @register_box("B")
      class B(ToyBaseBoxes):
          pass
  
      @register_box("C")
      class C(ToyBaseBoxes):
          pass
  
      converter = MagicMock()
      converter.return_value = torch.rand(3, 4, 4)
      register_box_converter("A", "B", converter)
  
      bboxes_a = A(torch.rand(3, 4, 4))
      th_bboxes_a = bboxes_a.tensor
      np_bboxes_a = th_bboxes_a.numpy()
  
      # test convert to mode
      convert_box_type(bboxes_a, dst_type="B")
      self.assertTrue(converter.called)
      converted_bboxes = convert_box_type(bboxes_a, dst_type="A")
      self.assertIs(converted_bboxes, bboxes_a)
      # test convert to unregistered mode
      with self.assertRaises(AssertionError):
          convert_box_type(bboxes_a, dst_type="C")
  
      # test convert tensor and ndarray
      # without specific src_type
      with self.assertRaises(AssertionError):
          convert_box_type(th_bboxes_a, dst_type="B")
      with self.assertRaises(AssertionError):
          convert_box_type(np_bboxes_a, dst_type="B")
      # test np.ndarray
      convert_box_type(np_bboxes_a, src_type="A", dst_type="B")
      converted_bboxes = convert_box_type(
          np_bboxes_a, src_type="A", dst_type="A"
      )
      self.assertIs(converted_bboxes, np_bboxes_a)
      # test tensor
      convert_box_type(th_bboxes_a, src_type="A", dst_type="B")
      converted_bboxes = convert_box_type(
          th_bboxes_a, src_type="A", dst_type="A"
      )
      self.assertIs(converted_bboxes, th_bboxes_a)
      # test other type
      with self.assertRaises(TypeError):
          convert_box_type([[1, 2, 3, 4]], src_type="A", dst_type="B")
  
file_path: mmdetection/tests/test_structures/test_bbox/test_box_type.py
imports: from unittest import TestCase
  from unittest.mock import MagicMock
  import torch
  from mmdet.structures.bbox.box_type import _box_type_to_name, box_converters, box_types, convert_box_type, get_box_type, register_box, register_box_converter
  from .utils import ToyBaseBoxes
label_desc: Use image node_id 6 for calling the TestBoxType obj's underlying member method code with example usage: obj.test_convert_box_type() without return types