code: def _step_with_closure(self, closure):
      def wrapped_closure():
          # helpful for debugging
          # print("Calling wrapped_closure, first_closure_call_this_step = {}"
          #       .format(self.first_closure_call_this_step))
          if self.first_closure_call_this_step:
              # We expect that the fp16 params are initially fresh on entering self.step(),
              # so _master_params_to_model_params() is unnecessary the first time wrapped_closure()
              # is called within self.optimizer.step().
              self.first_closure_call_this_step = False
          else:
              # If self.optimizer.step() internally calls wrapped_closure more than once,
              # it may update the fp32 params after each call.  However, self.optimizer
              # doesn't know about the fp16 params at all.  If the fp32 params get updated,
              # we can't rely on self.optimizer to refresh the fp16 params.  We need
              # to handle that manually:
              self._master_params_to_model_params()
          # Our API expects the user to give us ownership of the backward() call by
          # replacing all calls to loss.backward() with optimizer.backward(loss).
          # This requirement holds whether or not the call to backward() is made within a closure.
          # If the user is properly calling optimizer.backward(loss) within "closure,"
          # calling closure() here will give the fp32 master params fresh gradients
          # for the optimizer to play with, so all wrapped_closure needs to do is call
          # closure() and return the loss.
          temp_loss = closure()
          while self.overflow:
              scale = self.loss_scaler.loss_scale()
              # self._update_scale(self.overflow) # now done at the end of backward
              print(
                  "OVERFLOW within closure! Skipping step, reducing loss scale to {}".format(
                      self.loss_scaler.loss_scale()
                  )
              )
              temp_loss = closure()
          return temp_loss
  
      retval = self.optimizer.step(wrapped_closure)
  
      self.first_closure_call_this_step = True
  
      return retval
  
imports: import torch
  from torch import nn
  from torch.autograd import Variable
  from torch.nn.parameter import Parameter
  from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors
  from ..amp._amp_state import _amp_state, maybe_print
  from ..amp.scaler import LossScaler
  from ..multi_tensor_apply import multi_tensor_applier
  from .fp16util import model_grads_to_master_grads, master_params_to_model_params, clip_grad_norm
label_desc: Use image node_id 11 for calling the FP16_Optimizer obj's underlying member method code with example usage: obj._step_with_closure(closure) and returns: retval, temp_loss