import torch


def randperm_static(batch_size, proba_static=0):
    """
    Perform random permutation with a set percentage remaining fixed
    """
    if proba_static <= 0:
        return torch.randperm(batch_size)
    size_static = int(batch_size * proba_static)
    torch_static = torch.arange(0, size_static).long()
    size_shuffled = int(batch_size) - size_static
    torch_shuffled = size_static + torch.randperm(size_shuffled)
    return torch.cat([torch_static, torch_shuffled])