def swap(s1, s2, A):
    """Applies the Swap operator onto two sets of samples, `s1` and `s2`.

    The sites that will be swapped are defined by `A`.

    :param s1: A rank 2 tensor of spin samples representing the first replica.
    :type s1: torch.Tensor
    :param s2: A rank 2 tensor of spin samples representing the second replica.
    :type s2: torch.Tensor
    :param A: The sites that will be swapped between the two replicas.
    :type A: int or list or np.array or torch.Tensor
    """
    _s = s1[:, (A)].clone()
    s1[:, (A)] = s2[:, (A)]
    s2[:, (A)] = _s
    return s1, s2
