code: def testSparseDevicePlacement(self):
      with ops.Graph().as_default():
          for index_dtype in [dtypes.int32, dtypes.int64]:
              with self.cached_session(
                  force_gpu=test.is_gpu_available()
              ):
                  # If a GPU is available, tests that all optimizer ops can be placed on
                  # it (i.e. they have GPU kernels).
                  var = variables.Variable([[1.0], [2.0]])
                  indices = constant_op.constant(
                      [0, 1], dtype=index_dtype
                  )
                  gathered_sum = math_ops.reduce_sum(
                      array_ops.gather(var, indices)
                  )
                  optimizer = adam.AdamOptimizer(3.0)
                  minimize_op = optimizer.minimize(gathered_sum)
                  self.evaluate(
                      variables.global_variables_initializer()
                  )
                  minimize_op.run()
  
imports: import numpy
  from tensorflow.python.client import session
  from tensorflow.python.compiler.xla.experimental import xla_sharding
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import ref_variable
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import adam
label_desc: Use image node_id 4 for calling the AdamOptimizerTest obj's underlying member method code with example usage: obj.testSparseDevicePlacement() without return types