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 __init__(
      self,
      *,
      optimizer,
      learning_rate,
      gradient_norm_clipping=None,
      name=None,
      arguments_spec=None,
      **kwargs,
  ):
      super().__init__(name=name, arguments_spec=arguments_spec)
  
      assert optimizer in tensorflow_optimizers
      self.tf_optimizer = tensorflow_optimizers[optimizer]
  
      self.learning_rate = self.submodule(
          name="learning_rate",
          module=learning_rate,
          modules=parameter_modules,
          dtype="float",
          min_value=0.0,
      )
  
      if gradient_norm_clipping is None:
          self.gradient_norm_clipping = None
      else:
          self.gradient_norm_clipping = self.submodule(
              name="gradient_norm_clipping",
              module=gradient_norm_clipping,
              modules=parameter_modules,
              dtype="float",
              min_value=0.0,
          )
  
      self.optimizer_kwargs = kwargs
  
      def compose(function1, function2):
          def composed(*args, **kwargs):
              return function1(function2(*args, **kwargs))
  
          return composed
  
      if "decoupled_weight_decay" in self.optimizer_kwargs:
          decoupled_weight_decay = self.optimizer_kwargs.pop(
              "decoupled_weight_decay"
          )
          self.tf_optimizer = partial(
              tfa.optimizers.extend_with_decoupled_weight_decay(
                  base_optimizer=self.tf_optimizer
              ),
              weight_decay=decoupled_weight_decay,
          )
      if "lookahead" in self.optimizer_kwargs:
          lookahead = self.optimizer_kwargs.pop("lookahead")
          if isinstance(lookahead, dict) or lookahead is True:
              if lookahead is True:
                  lookahead = dict()
              self.tf_optimizer = compose(
                  function1=partial(
                      tfa.optimizers.Lookahead,
                      name=self.name,
                      **lookahead,
                  ),
                  function2=self.tf_optimizer,
              )
      if "moving_average" in self.optimizer_kwargs:
          moving_avg = self.optimizer_kwargs.pop("moving_average")
          if isinstance(moving_avg, dict) or moving_avg is True:
              if moving_avg is True:
                  moving_avg = dict()
              self.tf_optimizer = compose(
                  function1=partial(
                      tfa.optimizers.MovingAverage,
                      name=self.name,
                      **moving_avg,
                  ),
                  function2=self.tf_optimizer,
              )
  
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 1 to create a new TFOptimizer object from inherited base classes: Optimizer with example: obj = TFOptimizer()