code: def testSparse(self):
      if self.primary_device in ("GPU", "TPU"):
          self.skipTest(
              "IndexedSlices not supported on {}.".format(
                  self.primary_device
              )
          )
  
      parameters = [
          tf.Variable([[1.0], [2.0]]),
          tf.Variable([[3.0], [4.0]]),
      ]
      updates = [
          tf.IndexedSlices(
              tf.constant([0.1], shape=[1, 1]),
              tf.constant([0]),
              tf.constant([2, 1]),
          ),
          tf.IndexedSlices(
              tf.constant([0.01], shape=[1, 1]),
              tf.constant([1]),
              tf.constant([2, 1]),
          ),
      ]
      optimizer = self.make_optimizer(learning_rate=3.0, momentum=0.9)
      # Step 1 of Momentum
      optimizer.apply(updates, parameters)
      self.assertAllClose(
          [[1.0 - 3.0 * 0.1], [2.0]], parameters[0].numpy()
      )
      self.assertAllClose(
          [[3.0], [4.0 - 3.0 * 0.01]], parameters[1].numpy()
      )
      # Step 2 of Momentum
      optimizer.apply(updates, parameters)
      self.assertAllClose(
          [[0.7 - 3.0 * 0.19], [2.0]], parameters[0].numpy()
      )
      self.assertAllClose(
          [[3.0], [3.97 - 3.0 * 0.019]], parameters[1].numpy()
      )
      # Step 3 of Momentum
      optimizer.apply(updates, parameters)
      self.assertAllClose(
          [[0.13 - 3.0 * 0.271], [2.0]], parameters[0].numpy()
      )
      self.assertAllClose(
          [[3.0], [3.913 - 3.0 * 0.0271]], parameters[1].numpy()
      )
  
imports: from sonnet.src import test_utils
  from sonnet.src.optimizers import momentum
  from sonnet.src.optimizers import optimizer_tests
  import tensorflow
label_desc: Use image node_id 4 for calling the MomentumTest obj's underlying member method code with example usage: obj.testSparse() without return types