def get_branges_scales(x, sample_drop_ratio=0.0):
    """Add bernoulli sampled range and scale."""
    b, n, d = x.shape
    sample_subset_size = max(int(b * (1 - sample_drop_ratio)), 1)
    brange = (torch.randperm(b, device=x.device))[:sample_subset_size]
    residual_scale_factor = b / sample_subset_size
    return brange, residual_scale_factor
Add bernoulli sampled range and scale.
kornia/feature/dedode/transformer/layers/block.py