import torch


def get_isotopic_generalized_location(S, p):
    """ Given a list of spatial location, create the generalized measurement
    vector that corresponds to measuring ALL responses at those locations.

    Parameters
    ----------
    S: (M, d) Tensor
        List of spatial locations.
    p: int
        Number of responses.

    Returns
    -------
    S_iso: (M * p, d) Tensor
        Location tensor repeated p times.
    L_iso: (M * p) Tensor
        Response index vector for isotopic measurement.

    """
    # Generate index list
    inds = torch.Tensor([list(range(p))]).long().reshape(-1)
    # Repeat it by the number of cells.
    inds_iso = inds.repeat(S.shape[0]).long()

    # Repeat the cells.
    S_iso = S.repeat_interleave(p, dim=0)

    return S_iso, inds_iso