import torch


def mask_idx(lvl, edge_mask):
    """
    Converts a multi-scale edge_mask to a list of indices of edges corresponding to scale lvl.
    :param lvl: the desired scale lvl.
    :param edge_mask: a multi-scale edge mask.
    """
    mask = torch.nonzero(edge_mask & (0b1 << lvl), as_tuple=False).flatten()
    return mask