def METHOD_NAME(self, closure=None):
    if self.gradient_state.sync_gradients:
        if self.accelerator_state.distributed_type == DistributedType.TPU:
            optimizer_args = {"closure": closure} if closure is not None else {}
            xm.optimizer_step(self.optimizer, optimizer_args=optimizer_args)
        elif self.scaler is not None:
            self.optimizer.METHOD_NAME = self._optimizer_patched_step_method
            self.scaler.METHOD_NAME(self.optimizer, closure)
            self.scaler.update()
            if not self._accelerate_step_called:
                # If the optimizer step was skipped, gradient overflow was detected.
                self._is_overflow = True
            else:
                self._is_overflow = False
            # Reset the step method to the original one
            self.optimizer.METHOD_NAME = self._optimizer_original_step_method
            # Reset the indicator
            self._accelerate_step_called = False
        else:
            self.optimizer.METHOD_NAME(closure)