class_docstr: Optimizer for Tensors rather than tf.Variables.
  
  TensorOptimizers implement optimizers where the values being optimized
  are ordinary Tensors, rather than Variables. TF Variables can have strange
  behaviors when being assigned multiple times within a single sess.run()
  call, particularly in Distributed TF, so this avoids thinking about those
  issues. These are helper classes for the `projected_optimization`
  method. Apart from not using Variables, they follow an interface very
  similar to tf.Optimizer.
docstr: Compute a new value of `x` to minimize `loss_fn`.
  
  Args:
      loss_fn: a callable that takes `x`, a batch of images, and returns
          a batch of loss values. `x` will be optimized to minimize
          `loss_fn(x)`.
      x: A list of Tensors, the values to be updated. This is analogous
          to the `var_list` argument in standard TF Optimizer.
      unused_optim_state: A (possibly nested) dict, containing any state
          info needed for the optimizer.
  
  Returns:
      new_x: A list of Tensors, the same length as `x`, which are updated
      new_optim_state: A dict, with the same structure as `optim_state`,
          which have been updated.
docstr_tok: ["Compute","a","new","value","of","`","x","`","to","minimize","`","loss_fn","`",".","Args",":","loss_fn",":","a","callable","that","takes","`","x","`",",","a","batch","of","images",",","and","returns","a","batch","of","loss","values",".","`","x","`","will","be","optimized","to","minimize","`","loss_fn","(","x",")","`",".","x",":","A","list","of","Tensors",",","the","values","to","be","updated",".","This","is","analogous","to","the","`","var_list","`","argument","in","standard","TF","Optimizer",".","unused_optim_state",":","A","(","possibly","nested",")","dict",",","containing","any","state","info","needed","for","the","optimizer",".","Returns",":","new_x",":","A","list","of","Tensors",",","the","same","length","as","`","x","`",",","which","are","updated","new_optim_state",":","A","dict",",","with","the","same","structure","as","`","optim_state","`",",","which","have","been","updated","."]
code: def _compute_gradients(self, loss_fn, x, unused_optim_state):
      """Compute a new value of `x` to minimize `loss_fn`.
  
      Args:
          loss_fn: a callable that takes `x`, a batch of images, and returns
              a batch of loss values. `x` will be optimized to minimize
              `loss_fn(x)`.
          x: A list of Tensors, the values to be updated. This is analogous
              to the `var_list` argument in standard TF Optimizer.
          unused_optim_state: A (possibly nested) dict, containing any state
              info needed for the optimizer.
  
      Returns:
          new_x: A list of Tensors, the same length as `x`, which are updated
          new_optim_state: A dict, with the same structure as `optim_state`,
              which have been updated.
      """
  
      # Assumes `x` is a list,
      # and contains a tensor representing a batch of images
      assert len(x) == 1 and isinstance(
          x, list
      ), "x should be a list and contain only one image tensor"
      x = x[0]
      loss = reduce_mean(loss_fn(x), axis=0)
      return tf.gradients(loss, x)
  
imports: import warnings
  import numpy
  from six.moves import xrange
  import tensorflow
  import tensorflow_addons
  from cleverhans.attacks.attack import Attack
  from cleverhans.compat import reduce_mean, reduce_sum, reduce_max
  from cleverhans.model import Model
  from cleverhans import utils_tf
label_desc: Use image node_id 1 for calling the TensorOptimizer obj's underlying member method code with example usage: obj._compute_gradients(loss_fn, x, unused_optim_state) and returns: tf