class_docstr: Conditional optimizer.
class_docstr_tok: ["Conditional","optimizer","."]
code: def compute_gradients(
      self, loss, var_list=None, **kwargs
  ):  # pylint: disable=arguments-differ
      if contrib.is_tf2:
          gradients = self._opt.get_gradients(loss, var_list)
          gradients = zip(gradients, var_list)
      else:
          gradients = self._opt.compute_gradients(
              loss, var_list, **kwargs
          )
  
      def cast_grad(g, v):
          if v is not None and g is not None:
              g = common_layers.cast_like(g, v)
          if self._zero_grads and g is None:
              g = tf.zeros_like(v)
          return (g, v)
  
      gradients = [cast_grad(g, v) for g, v in gradients]
      return gradients
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from tensor2tensor.layers import common_layers
  from tensor2tensor.utils import adafactor
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import misc_utils
  from tensor2tensor.utils import mlperf_log
  from tensor2tensor.utils import multistep_optimizer
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import yellowfin
  import tensorflow.compat.v1
  from tensorflow.python.framework import dtypes
label_desc: Use image node_id 2 for calling the ConditionalOptimizer obj's underlying member method code with example usage: obj.compute_gradients(loss, var_list) and returns: gradients, g,  v