(*operands, **kwargs)
return fn(einsum_str, *operands, **kwargs)
Base einsum, but with pre-parse for valid characters if a string is given.
Base einsum, but with pre-parse for valid characters if a string is given.
Base einsum but with pre - parse for valid characters if a string is given .
def _einsum(*operands, **kwargs):
    """Base einsum, but with pre-parse for valid characters if a string is given."""
    fn = backends.get_func("einsum", kwargs.pop("backend", "numpy"))

    if not isinstance(operands[0], str):
        return fn(*operands, **kwargs)

    einsum_str, operands = operands[0], operands[1:]

    # Do we need to temporarily map indices into [a-z,A-Z] range?
    if not parser.has_valid_einsum_chars_only(einsum_str):

        # Explicitly find output str first so as to maintain order
        if "->" not in einsum_str:
            einsum_str += "->" + parser.find_output_str(einsum_str)

        einsum_str = parser.convert_to_valid_einsum_chars(einsum_str)

    return fn(einsum_str, *operands, **kwargs)
def _einsum ( * operands , * * kwargs ) : fn = backends . get_func ( "einsum" , kwargs . pop ( "backend" , "numpy" ) ) if not isinstance ( operands [ 0 ] , str ) : return fn ( * operands , * * kwargs ) einsum_str , operands = operands [ 0 ] , operands [ 1 : ] # Do we need to temporarily map indices into [a-z,A-Z] range? if not parser . has_valid_einsum_chars_only ( einsum_str ) : # Explicitly find output str first so as to maintain order if "->" not in einsum_str : einsum_str += "->" + parser . find_output_str ( einsum_str ) einsum_str = parser . convert_to_valid_einsum_chars ( einsum_str ) return fn ( einsum_str , * operands , * * kwargs )