def _no_grad_trunc_normal_(tensor: Tensor, mean: float, std: float, a: float, b: float) -> Tensor:

    def norm_cdf(x):
        return ((1.0 + math.erf((x / math.sqrt(2.0)))) / 2.0)
    if ((mean < (a - (2 * std))) or (mean > (b + (2 * std)))):
        warnings.warn('mean is more than 2 std from [a, b] in nn.init.trunc_normal_. The distribution of values may be incorrect.', stacklevel=2)
    with torch.no_grad():
        lower = norm_cdf(((a - mean) / std))
        upper = norm_cdf(((b - mean) / std))
        tensor.uniform_(((2 * lower) - 1), ((2 * upper) - 1))
        tensor.erfinv_()
        tensor.mul_((std * math.sqrt(2.0)))
        tensor.add_(mean)
        tensor.clamp_(min=a, max=b)
        return tensor
def _no_grad_trunc_normal_(tensor: Tensor, mean: float, std: float, a: float, b: float) -> Tensor:

    def norm_cdf(x):
        return ((1.0 + math.erf((x / math.sqrt(2.0)))) / 2.0)
    if ((mean < (a - (2 * std))) or (mean > (b + (2 * std)))):
        warnings.warn('mean is more than 2 std from [a, b] in nn.init.trunc_normal_. The distribution of values may be incorrect.', stacklevel=2)
    with torch.no_grad():
        lower = norm_cdf(((a - mean) / std))
        upper = norm_cdf(((b - mean) / std))
        tensor.uniform_(((2 * lower) - 1), ((2 * upper) - 1))
        tensor.erfinv_()
        tensor.mul_((std * math.sqrt(2.0)))
        tensor.add_(mean)
        tensor.clamp_(min=a, max=b)
        return tensor