def check_finite_loss(loss: Optional[Tensor]) -> None:
    """Checks for finite loss value.

    Args:
        loss: the loss value to check to be finite

    """
    if loss is not None and not torch.isfinite(loss).all():
        raise ValueError(f"The loss returned in `training_step` is {loss}.")
Checks for finite loss value.

    Args:
        loss: the loss value to check to be finite

    
src/lightning/pytorch/loops/utilities.py