def run_training_batch(self, batch, batch_idx, dataloader_idx):
    grad_norm_dic = {}
    self.trainer.hiddens = None
    optimizers = self.prepare_optimizers()
    batch_outputs = [[] for _ in range(len(optimizers))]
    if (batch is None):
        self.warning_cache.warn('train_dataloader yielded None. If this was on purpose, ignore this warning...')
        return AttributeDict(signal=0, grad_norm_dic=grad_norm_dic, training_step_output_for_epoch_end=batch_outputs)
    response = self.trainer.call_hook('on_batch_start')
    if (response == (- 1)):
        return AttributeDict(signal=(- 1), grad_norm_dic=grad_norm_dic)
    response = self.trainer.call_hook('on_train_batch_start', batch, batch_idx, dataloader_idx)
    if (response == (- 1)):
        return AttributeDict(signal=(- 1), grad_norm_dic=grad_norm_dic)
    splits = self._tbptt_split_batch(batch)
    for (split_idx, split_batch) in enumerate(splits):
        for (opt_idx, optimizer) in optimizers:
            self.run_train_split_start(split_idx, split_batch, opt_idx, optimizer)
            if self.should_accumulate():
                with self.block_ddp_sync_behaviour():
                    self.training_step_and_backward(split_batch, batch_idx, opt_idx, optimizer, self.trainer.hiddens)
                batch_outputs = self._process_closure_result(batch_outputs=batch_outputs, opt_idx=opt_idx)
            else:
                if self.trainer.lightning_module.automatic_optimization:

                    def train_step_and_backward_closure():
                        result = self.training_step_and_backward(split_batch, batch_idx, opt_idx, optimizer, self.trainer.hiddens)
                        return (None if (result is None) else result.loss)
                    self.optimizer_step(optimizer, opt_idx, batch_idx, train_step_and_backward_closure)
                else:
                    self._curr_step_result = self.training_step(split_batch, batch_idx, opt_idx, self.trainer.hiddens)
                if (self._curr_step_result is None):
                    continue
                batch_outputs = self._process_closure_result(batch_outputs=batch_outputs, opt_idx=opt_idx)
                grad_norm_dic = self._cur_grad_norm_dict
                self._cur_grad_norm_dict = None
                self.update_running_loss()
    result = AttributeDict(signal=0, grad_norm_dic=grad_norm_dic, training_step_output_for_epoch_end=batch_outputs)
    return result
def run_training_batch(self, batch, batch_idx, dataloader_idx):
    grad_norm_dic = {}
    self.trainer.hiddens = None
    optimizers = self.prepare_optimizers()
    batch_outputs = [[] for _ in range(len(optimizers))]
    if (batch is None):
        self.warning_cache.warn('train_dataloader yielded None. If this was on purpose, ignore this warning...')
        return AttributeDict(signal=0, grad_norm_dic=grad_norm_dic, training_step_output_for_epoch_end=batch_outputs)
    response = self.trainer.call_hook('on_batch_start')
    if (response == (- 1)):
        return AttributeDict(signal=(- 1), grad_norm_dic=grad_norm_dic)
    response = self.trainer.call_hook('on_train_batch_start', batch, batch_idx, dataloader_idx)
    if (response == (- 1)):
        return AttributeDict(signal=(- 1), grad_norm_dic=grad_norm_dic)
    splits = self._tbptt_split_batch(batch)
    for (split_idx, split_batch) in enumerate(splits):
        for (opt_idx, optimizer) in optimizers:
            self.run_train_split_start(split_idx, split_batch, opt_idx, optimizer)
            if self.should_accumulate():
                with self.block_ddp_sync_behaviour():
                    self.training_step_and_backward(split_batch, batch_idx, opt_idx, optimizer, self.trainer.hiddens)
                batch_outputs = self._process_closure_result(batch_outputs=batch_outputs, opt_idx=opt_idx)
            else:
                if self.trainer.lightning_module.automatic_optimization:

                    def train_step_and_backward_closure():
                        result = self.training_step_and_backward(split_batch, batch_idx, opt_idx, optimizer, self.trainer.hiddens)
                        return (None if (result is None) else result.loss)
                    self.optimizer_step(optimizer, opt_idx, batch_idx, train_step_and_backward_closure)
                else:
                    self._curr_step_result = self.training_step(split_batch, batch_idx, opt_idx, self.trainer.hiddens)
                if (self._curr_step_result is None):
                    continue
                batch_outputs = self._process_closure_result(batch_outputs=batch_outputs, opt_idx=opt_idx)
                grad_norm_dic = self._cur_grad_norm_dict
                self._cur_grad_norm_dict = None
                self.update_running_loss()
    result = AttributeDict(signal=0, grad_norm_dic=grad_norm_dic, training_step_output_for_epoch_end=batch_outputs)
    return result