import torch


def _mean_plus_r_var(data: torch.Tensor, ratio: float = 0, **kwargs) -> float:
    """
    Caclulates mean + ratio x standard_deviation of the provided tensor
    and returns the larger of this value and the smallest element in
    the tensor (can happen when ratio is negative).

    Parameters
    ----------
    data: torch.Tensor
        Pytorch tensor containing the data on which the mean and stdv.
        is evaluated.

    ratio: float, optional
        Value of the scaling factor in the value calculated by the
        function.

    Returns
    -------
    float
        The result of the function.

    """
    return max(data.min().item(), data.mean().item() + ratio * data.std().item() + 1e-8)