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]]),
      ]
      tf_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=0.001)
  
      # Compare against TF optimizer.
      tf_optimizer = tf.optimizers.Adam(learning_rate=0.001)
      # Step 1 of Adam
      optimizer.apply(updates, parameters)
      self.assertAllClose([[0.999], [2.0]], parameters[0].numpy())
      self.assertAllClose([[3.0], [3.999]], parameters[1].numpy())
      tf_optimizer.apply_gradients(zip(updates, tf_parameters))
      self.assertAllClose(
          tf_parameters[0].numpy(), parameters[0].numpy()
      )
      self.assertAllClose(
          tf_parameters[1].numpy(), parameters[1].numpy()
      )
      # Step 2 of Adam
      optimizer.apply(updates, parameters)
      self.assertAllClose([[0.998], [2.0]], parameters[0].numpy())
      self.assertAllClose([[3.0], [3.998]], parameters[1].numpy())
      tf_optimizer.apply_gradients(zip(updates, tf_parameters))
      self.assertAllClose(
          tf_parameters[0].numpy(), parameters[0].numpy()
      )
      self.assertAllClose(
          tf_parameters[1].numpy(), parameters[1].numpy()
      )
      # Step 3 of Adam
      optimizer.apply(updates, parameters)
      self.assertAllClose([[0.997], [2.0]], parameters[0].numpy())
      self.assertAllClose([[3.0], [3.997]], parameters[1].numpy())
      tf_optimizer.apply_gradients(zip(updates, tf_parameters))
      self.assertAllClose(
          tf_parameters[0].numpy(), parameters[0].numpy()
      )
      self.assertAllClose(
          tf_parameters[1].numpy(), parameters[1].numpy()
      )
  
file_path: sonnet/sonnet/src/optimizers/adam_test.py
imports: from sonnet.src import test_utils
  from sonnet.src.optimizers import adam
  from sonnet.src.optimizers import optimizer_tests
  import tensorflow
label_desc: Use image node_id 3 for calling the AdamTest obj's underlying member method code with example usage: obj.testSparse() without return types