code: def test_index(self):
      reference = consec((3, 3, 3))
  
      numpy_testing_assert_equal_helper(reference[0], consec((3, 3)))
      numpy_testing_assert_equal_helper(
          reference[1], consec((3, 3), 10)
      )
      numpy_testing_assert_equal_helper(
          reference[2], consec((3, 3), 19)
      )
      numpy_testing_assert_equal_helper(
          reference[0, 1], consec((3,), 4)
      )
      numpy_testing_assert_equal_helper(
          reference[0:2], consec((2, 3, 3))
      )
      numpy_testing_assert_equal_helper(reference[2, 2, 2], 27)
      numpy_testing_assert_equal_helper(reference[:], consec((3, 3, 3)))
  
      # indexing with Ellipsis
      numpy_testing_assert_equal_helper(
          reference[..., 2],
          np.array(
              [[3.0, 6.0, 9.0], [12.0, 15.0, 18.0], [21.0, 24.0, 27.0]]
          ),
      )
      numpy_testing_assert_equal_helper(
          reference[0, ..., 2], np.array([3.0, 6.0, 9.0])
      )
      numpy_testing_assert_equal_helper(
          reference[..., 2], reference[:, :, 2]
      )
      numpy_testing_assert_equal_helper(
          reference[0, ..., 2], reference[0, :, 2]
      )
      numpy_testing_assert_equal_helper(
          reference[0, 2, ...], reference[0, 2]
      )
      numpy_testing_assert_equal_helper(reference[..., 2, 2, 2], 27)
      numpy_testing_assert_equal_helper(reference[2, ..., 2, 2], 27)
      numpy_testing_assert_equal_helper(reference[2, 2, ..., 2], 27)
      numpy_testing_assert_equal_helper(reference[2, 2, 2, ...], 27)
      numpy_testing_assert_equal_helper(reference[...], reference)
  
      reference_5d = consec((3, 3, 3, 3, 3))
      numpy_testing_assert_equal_helper(
          reference_5d[..., 1, 0], reference_5d[:, :, :, 1, 0]
      )
      numpy_testing_assert_equal_helper(
          reference_5d[2, ..., 1, 0], reference_5d[2, :, :, 1, 0]
      )
      numpy_testing_assert_equal_helper(
          reference_5d[2, 1, 0, ..., 1], reference_5d[2, 1, 0, :, 1]
      )
      numpy_testing_assert_equal_helper(reference_5d[...], reference_5d)
  
      # None indexing
      numpy_testing_assert_equal_helper(
          reference[2, None], reference[2].unsqueeze(0)
      )
      numpy_testing_assert_equal_helper(
          reference[2, None, None],
          reference[2].unsqueeze(0).unsqueeze(0),
      )
      numpy_testing_assert_equal_helper(
          reference[2:4, None], reference[2:4].unsqueeze(1)
      )
      numpy_testing_assert_equal_helper(
          reference[None, 2, None, None],
          reference.unsqueeze(0)[:, 2].unsqueeze(0).unsqueeze(0),
      )
      numpy_testing_assert_equal_helper(
          reference[None, 2:5, None, None],
          reference.unsqueeze(0)[:, 2:5].unsqueeze(2).unsqueeze(2),
      )
  
      # indexing 0-length slice
      numpy_testing_assert_equal_helper(
          np.empty((0, 3, 3)), reference[slice(0)]
      )
      numpy_testing_assert_equal_helper(
          np.empty((0, 3)), reference[slice(0), 2]
      )
      numpy_testing_assert_equal_helper(
          np.empty((0, 3)), reference[2, slice(0)]
      )
      numpy_testing_assert_equal_helper(
          np.empty([]), reference[2, 1:1, 2]
      )
  
      # indexing with step
      reference = consec((10, 10, 10))
      numpy_testing_assert_equal_helper(
          reference[1:5:2],
          Tensor.stack([reference[1], reference[3]], 0),
      )
      numpy_testing_assert_equal_helper(
          reference[1:6:2],
          Tensor.stack([reference[1], reference[3], reference[5]], 0),
      )
      numpy_testing_assert_equal_helper(
          reference[1:9:4],
          Tensor.stack([reference[1], reference[5]], 0),
      )
      numpy_testing_assert_equal_helper(
          reference[2:4, 1:5:2],
          Tensor.stack([reference[2:4, 1], reference[2:4, 3]], 1),
      )
      numpy_testing_assert_equal_helper(
          reference[3, 1:6:2],
          Tensor.stack(
              [reference[3, 1], reference[3, 3], reference[3, 5]], 0
          ),
      )
      numpy_testing_assert_equal_helper(
          reference[None, 2, 1:9:4],
          Tensor.stack([reference[2, 1], reference[2, 5]], 0).unsqueeze(
              0
          ),
      )
      numpy_testing_assert_equal_helper(
          reference[:, 2, 1:6:2],
          Tensor.stack(
              [
                  reference[:, 2, 1],
                  reference[:, 2, 3],
                  reference[:, 2, 5],
              ],
              1,
          ),
      )
  
      lst = [list(range(i, i + 10)) for i in range(0, 100, 10)]
      tensor = Tensor(lst)
      for _ in range(100):
          idx1_start = random.randrange(10)
          idx1_end = idx1_start + random.randrange(
              1, 10 - idx1_start + 1
          )
          idx1_step = random.randrange(1, 8)
          idx1 = slice(idx1_start, idx1_end, idx1_step)
          if random.randrange(2) == 0:
              idx2_start = random.randrange(10)
              idx2_end = idx2_start + random.randrange(
                  1, 10 - idx2_start + 1
              )
              idx2_step = random.randrange(1, 8)
              idx2 = slice(idx2_start, idx2_end, idx2_step)
              lst_indexed = [l[idx2] for l in lst[idx1]]
              tensor_indexed = tensor[idx1, idx2]
          else:
              lst_indexed = lst[idx1]
              tensor_indexed = tensor[idx1]
          numpy_testing_assert_equal_helper(
              tensor_indexed, np.array(lst_indexed)
          )
  
      self.assertRaises(ValueError, lambda: reference[1:9:0])
      # NOTE torch doesn't support this but numpy does so we should too. Torch raises ValueError
      # see test_slice_negative_strides in test_ops.py
      # self.assertRaises(ValueError, lambda: reference[1:9:-1])
  
      self.assertRaises(IndexError, lambda: reference[1, 1, 1, 1])
      self.assertRaises(IndexError, lambda: reference[1, 1, 1, 1:1])
      self.assertRaises(
          IndexError, lambda: reference[3, 3, 3, 3, 3, 3, 3, 3]
      )
  
      self.assertRaises(IndexError, lambda: reference[0.0])
      self.assertRaises(TypeError, lambda: reference[0.0:2.0])
      self.assertRaises(IndexError, lambda: reference[0.0, 0.0:2.0])
      self.assertRaises(IndexError, lambda: reference[0.0, :, 0.0:2.0])
      self.assertRaises(
          IndexError, lambda: reference[0.0, ..., 0.0:2.0]
      )
      self.assertRaises(IndexError, lambda: reference[0.0, :, 0.0])
  
imports: import math, unittest, random, copy
  import numpy
  from tinygrad import Tensor, dtypes, Device
  from tinygrad.lazy import LazyBuffer
  from tinygrad.shape.shapetracker import ShapeTracker
  from tinygrad.shape.view import View
  from tinygrad.helpers import CI
label_desc: Use image node_id 1 for calling the TestIndexing obj's underlying member method code with example usage: obj.test_index() without return types