import torch


def rand_with_zeros(N: int, ps:int, indices, X):
    """
    Random matrix (normal distribution) with mask.

    Arguments:
        N (int): Number of pixels.
        ps (int): Number of probing vectors.
        scale (int): Scaling factor due to pseudo-orthogonalization overlap.
        indices (Tensor): Non zero indices, same for all pixels.
        X (Tensor): Input tensor (untouched, used for device detection).
    """
    n = indices.shape[0]
    a = torch.zeros(N, ps, device=X.device)
    a[:, indices] = torch.randn(N, n, device=X.device)
    return torch.sqrt(ps/n)*a