code: def test_getitem(self):
      boxes = ToyBaseBoxes(torch.rand(3, 4, 4))
  
      # test single dimension index
      # int
      new_boxes = boxes[0]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (4, 4))
      # list
      new_boxes = boxes[[0, 2]]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (2, 4, 4))
      # slice
      new_boxes = boxes[0:2]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (2, 4, 4))
      # torch.LongTensor
      new_boxes = boxes[torch.LongTensor([0, 1])]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (2, 4, 4))
      # torch.BoolTensor
      new_boxes = boxes[torch.BoolTensor([True, False, True])]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (2, 4, 4))
      with self.assertRaises(AssertionError):
          index = torch.rand((2, 4, 4)) > 0
          new_boxes = boxes[index]
  
      # test multiple dimension index
      # select single box
      new_boxes = boxes[1, 2]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (1, 4))
      # select the last dimension
      with self.assertRaises(AssertionError):
          new_boxes = boxes[1, 2, 1]
      # has Ellipsis
      new_boxes = boxes[None, ...]
      self.assertIsInstance(new_boxes, ToyBaseBoxes)
      self.assertEqual(new_boxes.tensor.shape, (1, 3, 4, 4))
      with self.assertRaises(AssertionError):
          new_boxes = boxes[..., None]
  
file_path: mmdetection/tests/test_structures/test_bbox/test_base_boxes.py
imports: from unittest import TestCase
  import numpy
  import torch
  from mmengine.testing import assert_allclose
  from .utils import ToyBaseBoxes
label_desc: Use image node_id 2 for calling the TestBaseBoxes obj's underlying member method code with example usage: obj.test_getitem() without return types