code: def test_cluster_getitem(rng):
      indices = list(range(len(data)))
      rng.shuffle(indices)  # None trivial ordering
      advanced_indices = indices + [0, 1, 2, -1, -2, -3]
  
      # Test without specifying refdata in ClusterMap
      cluster = Cluster()
      cluster.assign(*indices)
  
      # Test indexing
      for i in advanced_indices:
          assert_equal(cluster[i], indices[i])
  
      # Test advanced indexing
      assert_array_equal(
          cluster[advanced_indices],
          [indices[i] for i in advanced_indices],
      )
  
      # Test index out of bounds
      assert_raises(IndexError, cluster.__getitem__, len(cluster))
      assert_raises(IndexError, cluster.__getitem__, -len(cluster) - 1)
  
      # Test slicing and negative indexing
      assert_equal(cluster[-1], indices[-1])
      assert_array_equal(cluster[::2], indices[::2])
      assert_arrays_equal(cluster[::-1], indices[::-1])
      assert_arrays_equal(cluster[:-1], indices[:-1])
      assert_arrays_equal(cluster[1:], indices[1:])
  
      # Test with wrong indexing object
      assert_raises(TypeError, cluster.__getitem__, "wrong")
  
      # Test with specifying refdata in ClusterMap
      cluster.refdata = data
  
      # Test indexing
      for i in advanced_indices:
          assert_array_equal(cluster[i], data[indices[i]])
  
      # Test advanced indexing
      assert_arrays_equal(
          cluster[advanced_indices],
          [data[indices[i]] for i in advanced_indices],
      )
  
      # Test index out of bounds
      assert_raises(IndexError, cluster.__getitem__, len(cluster))
      assert_raises(IndexError, cluster.__getitem__, -len(cluster) - 1)
  
      # Test slicing and negative indexing
      assert_array_equal(cluster[-1], data[indices[-1]])
      assert_arrays_equal(cluster[::2], [data[i] for i in indices[::2]])
      assert_arrays_equal(
          cluster[::-1], [data[i] for i in indices[::-1]]
      )
      assert_arrays_equal(cluster[:-1], [data[i] for i in indices[:-1]])
      assert_arrays_equal(cluster[1:], [data[i] for i in indices[1:]])
  
      # Test with wrong indexing object
      assert_raises(TypeError, cluster.__getitem__, "wrong")
  
imports: import copy
  import itertools
  import numpy
  from numpy.testing import assert_array_equal, assert_raises, assert_equal
  from dipy.segment.clustering import Cluster, ClusterCentroid
  from dipy.segment.clustering import ClusterMap, ClusterMapCentroid
  from dipy.segment.clustering import Clustering
  from dipy.testing import assert_true, assert_false, assert_arrays_equal
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 4 for calling a global function with example usage: test_cluster_getitem(rng) without return types