parameters: (self, loss, var_list=None, **kwargs)
return_statement: return self._opt.compute_gradients(loss, var_list=var_list, **kwargs)
docstring: Compute gradients of "loss" for the variables in "var_list".
  
      This simply wraps the compute_gradients() from the real optimizer. The
      gradients will be aggregated in the apply_gradients() so that user can
      modify the gradients like clipping with per replica global norm if needed.
      The global norm with aggregated gradients can be bad as one replica's huge
      gradients can hurt the gradients from other replicas.
  
      Args:
        loss: A Tensor containing the value to minimize.
        var_list: Optional list or tuple of `tf.Variable` to update to minimize
          `loss`.  Defaults to the list of variables collected in the graph
          under the key `GraphKey.TRAINABLE_VARIABLES`.
        **kwargs: Keyword arguments for compute_gradients().
  
      Returns:
        A list of (gradient, variable) pairs.
  
      Raises:
        ValueError: If not within a tpu_shard_context.
docstring_summary: Compute gradients of "loss" for the variables in "var_list".
docstring_tokens: Compute gradients of loss for the variables in var_list .
function: def compute_gradients(self, loss, var_list=None, **kwargs):
      """Compute gradients of "loss" for the variables in "var_list".
  
      This simply wraps the compute_gradients() from the real optimizer. The
      gradients will be aggregated in the apply_gradients() so that user can
      modify the gradients like clipping with per replica global norm if needed.
      The global norm with aggregated gradients can be bad as one replica's huge
      gradients can hurt the gradients from other replicas.
  
      Args:
        loss: A Tensor containing the value to minimize.
        var_list: Optional list or tuple of `tf.Variable` to update to minimize
          `loss`.  Defaults to the list of variables collected in the graph
          under the key `GraphKey.TRAINABLE_VARIABLES`.
        **kwargs: Keyword arguments for compute_gradients().
  
      Returns:
        A list of (gradient, variable) pairs.
  
      Raises:
        ValueError: If not within a tpu_shard_context.
      """
      num_shards = tpu_function.get_tpu_context().number_of_shards
      if num_shards is None:
        raise ValueError("CrossShardOptimizer must be used within a "
                         "tpu_shard_context.")
      if num_shards > 1 and self._reduction == losses.Reduction.MEAN:
        scale = 1.0 / num_shards
        loss *= scale
      return self._opt.compute_gradients(loss, var_list=var_list, **kwargs)
function_tokens: def compute_gradients ( self , loss , var_list = None , * * kwargs ) : num_shards = tpu_function . get_tpu_context ( ) . number_of_shards if num_shards is None : raise ValueError ( "CrossShardOptimizer must be used within a " "tpu_shard_context." ) if num_shards > 1 and self . _reduction == losses . Reduction . MEAN : scale = 1.0 / num_shards loss *= scale return self . _opt . compute_gradients ( loss , var_list = var_list , * * kwargs )