def _build_einsum_string(n_factors):
    """Builds a string for computing a tensor product."""
    if n_factors > 10:
        raise ValueError("Number of factors must be less than 10.")

    values = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'][:n_factors]

    return ", ".join(values) + " -> " + "".join(values)