class_docstr: Double-check update modifier, which checks whether the update of the given optimizer has
  decreased the loss and otherwise reverses it (specification key: `doublecheck_step`).
  
  Args:
      optimizer (specification): Optimizer configuration
          (<span style="color:#C00000"><b>required</b></span>).
      name (string): (<span style="color:#0000C0"><b>internal use</b></span>).
      arguments_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
class_docstr_tok: ["Double-check","update","modifier",",","which","checks","whether","the","update","of","the","given","optimizer","has","decreased","the","loss","and","otherwise","reverses","it","(","specification","key",":","`","doublecheck_step","`",")",".","Args",":","optimizer","(","specification",")",":","Optimizer","configuration","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","name","(","string",")",":","(","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",")",".","arguments_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def step(self, *, arguments, variables, fn_loss, **kwargs):
      loss_before = fn_loss(**arguments.to_kwargs())
  
      with tf.control_dependencies(control_inputs=(loss_before,)):
          deltas = self.optimizer.step(
              arguments=arguments,
              variables=variables,
              fn_loss=fn_loss,
              **kwargs,
          )
  
      with tf.control_dependencies(control_inputs=deltas):
          loss_after = fn_loss(**arguments.to_kwargs())
  
          def reverse_update():
              assignments = list()
              for variable, delta in zip(variables, deltas):
                  assignments.append(
                      variable.assign_add(
                          delta=-delta, read_value=False
                      )
                  )
              with tf.control_dependencies(control_inputs=assignments):
                  return [
                      tf.zeros_like(input=delta) for delta in deltas
                  ]
  
          is_improvement = loss_after < loss_before
          return tf.cond(
              pred=is_improvement,
              true_fn=(lambda: deltas),
              false_fn=reverse_update,
          )
  
imports: import tensorflow
  from tensorforce.core import tf_function
  from tensorforce.core.optimizers import UpdateModifier
label_desc: Use image node_id 1 for calling the DoublecheckStep obj's underlying member method code with example usage: obj.step() and returns: tf, unknown