class_docstr: TensorFlow optimizer (specification key: `tf_optimizer`, `adadelta`, `adagrad`, `adam`,
  `adamax`, `adamw`, `ftrl`, `lazyadam`, `nadam`, `radam`, `ranger`, `rmsprop`, `sgd`, `sgdw`)
  
  Args:
      optimizer (`adadelta` | `adagrad` | `adam` | `adamax` | `adamw` | `ftrl` | `lazyadam` | `nadam` | `radam` | `ranger` | `rmsprop` | `sgd` | `sgdw`):
          TensorFlow optimizer name, see
          `TensorFlow docs <https://www.tensorflow.org/api_docs/python/tf/keras/optimizers>`__
          and `TensorFlow Addons docs
          <https://www.tensorflow.org/addons/api_docs/python/tfa/optimizers>`__
          (<span style="color:#C00000"><b>required</b></span> unless given by specification key).
      learning_rate (parameter, float > 0.0): Learning rate
          (<span style="color:#C00000"><b>required</b></span>).
      gradient_norm_clipping (parameter, float > 0.0): Clip gradients by the ratio of the sum
          of their norms (<span style="color:#00C000"><b>default</b></span>: 1.0).
      name (string): (<span style="color:#0000C0"><b>internal use</b></span>).
      arguments_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      kwargs: Arguments for the TensorFlow optimizer, special values "decoupled_weight_decay",
          "lookahead" and "moving_average", see
          `TensorFlow docs <https://www.tensorflow.org/api_docs/python/tf/keras/optimizers>`__
          and `TensorFlow Addons docs
          <https://www.tensorflow.org/addons/api_docs/python/tfa/optimizers>`__.
code: def step(self, *, arguments, variables, fn_loss, **kwargs):
      # Trivial operation to enforce control dependency
      previous_values = list(
          tf_util.identity(input=variable) for variable in variables
      )
  
      # Remember variables before update
      with tf.control_dependencies(control_inputs=previous_values):
          with tf.GradientTape(
              persistent=False, watch_accessed_variables=False
          ) as tape:
              for variable in variables:
                  tape.watch(tensor=variable)
              loss = fn_loss(**arguments.to_kwargs())
  
          gradients = tape.gradient(
              target=loss, sources=variables
          )  # , output_gradients=initial
  
          assertions = list()
          gradients = list(gradients)
          grads_and_vars = list(zip(gradients, variables))
          for n in range(len(gradients) - 1, -1, -1):
              if gradients[n] is None:
                  gradients.pop(n)
                  grads_and_vars.pop(n)
              elif self.config.create_tf_assertions:
                  assertions.append(
                      tf.debugging.assert_all_finite(
                          x=gradients[n],
                          message="Invalid gradient: contains inf or nan.",
                      )
                  )
          assert len(gradients) > 0
  
      with tf.control_dependencies(control_inputs=assertions):
          dependencies = list()
          if self.gradient_norm_clipping is not None:
              clip_norm = self.gradient_norm_clipping.value()
              gradients, grads_norm = tf.clip_by_global_norm(
                  t_list=[
                      tf_util.cast(x=g, dtype="float")
                      for g in gradients
                  ],
                  clip_norm=clip_norm,
              )
              dependencies.extend(
                  self.summary(
                      label="update-norm",
                      name="unclipped-gradient-norm",
                      data=grads_norm,
                      step="updates",
                  )
              )
              grads_and_vars = [
                  (grad, var)
                  for grad, (_, var) in zip(gradients, grads_and_vars)
              ]
  
          applied = self.tf_optimizer.apply_gradients(
              grads_and_vars=grads_and_vars
          )
          dependencies.append(applied)
  
      # Return deltas after actually having change the variables.
      with tf.control_dependencies(control_inputs=dependencies):
          return [
              variable - previous
              for variable, previous in zip(variables, previous_values)
          ]
  
file_path: tensorforce/tensorforce/core/optimizers/tf_optimizer.py
imports: from functools import partial
  import tensorflow
  from tensorforce.core import parameter_modules, tf_function, tf_util
  from tensorforce.core.optimizers import Optimizer
label_desc: Use image node_id 4 for calling the TFOptimizer obj's underlying member method code with example usage: obj.step() and returns: unknown