import torch


def product(*inputs, r=1):
    """Cartesian product of a set.

    Parameters
    ----------
    inputs : iterable of tensor_like
        Input sets (tensors are flattened is not vectors)
        with `n[i]` elements each.
    r : int, default=1
        Repeats.
        .. warning:: keyword argument only.

    Returns
    -------
    output : (prod(n)**r, r) tensor
        Cartesian product

    """
    inputs = [torch.as_tensor(input) for input in inputs]
    return torch.cartesian_prod(*(inputs * r))