def _should_check_val_fx(self, batch_idx: int, is_last_batch: bool, on_epoch: bool=False) -> bool:
    ' Decide if we should run validation. '
    if (not self.trainer.enable_validation):
        return False
    if (((self.trainer.current_epoch + 1) % self.trainer.check_val_every_n_epoch) != 0):
        return False
    is_val_check_batch = False
    if (isinstance(self.trainer.limit_train_batches, int) and (self.trainer.val_check_batch == float('inf'))):
        is_val_check_batch = (((batch_idx + 1) % self.trainer.limit_train_batches) == 0)
    elif (self.trainer.val_check_batch != float('inf')):
        is_val_check_batch = (((batch_idx + 1) % self.trainer.val_check_batch) == 0)
    epoch_end_val_check = (((batch_idx + 1) % self.trainer.num_training_batches) == 0)
    is_last_batch_for_infinite_dataset = (is_last_batch and (self.trainer.val_check_batch == float('inf')))
    if on_epoch:
        return ((is_val_check_batch and epoch_end_val_check) or self.trainer.should_stop or is_last_batch_for_infinite_dataset)
    else:
        return (is_val_check_batch and (not epoch_end_val_check))
Decide if we should run validation.
def _should_check_val_fx(self, batch_idx: int, is_last_batch: bool, on_epoch: bool=False) -> bool:
    '  '
    if (not self.trainer.enable_validation):
        return False
    if (((self.trainer.current_epoch + 1) % self.trainer.check_val_every_n_epoch) != 0):
        return False
    is_val_check_batch = False
    if (isinstance(self.trainer.limit_train_batches, int) and (self.trainer.val_check_batch == float('inf'))):
        is_val_check_batch = (((batch_idx + 1) % self.trainer.limit_train_batches) == 0)
    elif (self.trainer.val_check_batch != float('inf')):
        is_val_check_batch = (((batch_idx + 1) % self.trainer.val_check_batch) == 0)
    epoch_end_val_check = (((batch_idx + 1) % self.trainer.num_training_batches) == 0)
    is_last_batch_for_infinite_dataset = (is_last_batch and (self.trainer.val_check_batch == float('inf')))
    if on_epoch:
        return ((is_val_check_batch and epoch_end_val_check) or self.trainer.should_stop or is_last_batch_for_infinite_dataset)
    else:
        return (is_val_check_batch and (not epoch_end_val_check))