code: def test_sparse_vector_indexing(self):
      sv = SparseVector(5, {1: 1, 3: 2})
      self.assertEqual(sv[0], 0.0)
      self.assertEqual(sv[3], 2.0)
      self.assertEqual(sv[1], 1.0)
      self.assertEqual(sv[2], 0.0)
      self.assertEqual(sv[4], 0.0)
      self.assertEqual(sv[-1], 0.0)
      self.assertEqual(sv[-2], 2.0)
      self.assertEqual(sv[-3], 0.0)
      self.assertEqual(sv[-5], 0.0)
      for ind in [5, -6]:
          self.assertRaises(IndexError, sv.__getitem__, ind)
      for ind in [7.8, "1"]:
          self.assertRaises(TypeError, sv.__getitem__, ind)
  
      zeros = SparseVector(4, {})
      self.assertEqual(zeros[0], 0.0)
      self.assertEqual(zeros[3], 0.0)
      for ind in [4, -5]:
          self.assertRaises(IndexError, zeros.__getitem__, ind)
  
      empty = SparseVector(0, {})
      for ind in [-1, 0, 1]:
          self.assertRaises(IndexError, empty.__getitem__, ind)
  
imports: import array
  import unittest
  from numpy import array, array_equal, zeros, arange, tile, ones, inf
  import pyspark.ml.linalg
  from pyspark.serializers import CPickleSerializer
  from pyspark.mllib.linalg import Vector, SparseVector, DenseVector, VectorUDT, _convert_to_vector, DenseMatrix, SparseMatrix, Vectors, Matrices, MatrixUDT
  from pyspark.mllib.linalg.distributed import RowMatrix, IndexedRowMatrix, IndexedRow
  from pyspark.mllib.regression import LabeledPoint
  from pyspark.sql import Row
  from pyspark.testing.mllibutils import MLlibTestCase
  from pyspark.testing.utils import have_scipy
label_desc: Use image node_id 9 for calling the VectorTests obj's underlying member method code with example usage: obj.test_sparse_vector_indexing() without return types