(
    inputs: List[FrozenSet[int]], all_inds: Tuple[str, ...], ind_counts: CounterType[str]
)
return inputs_parsed, inputs_done, inputs_contractions
Take `inputs` and parse for single term index operations, i.e. where
    an index appears on one tensor and nowhere else.

    If a term is completely reduced to a scalar in this way it can be removed
    to `inputs_done`. If only some indices can be summed then add a 'single
    term contraction' that will perform this summation.
Take `inputs` and parse for single term index operations, i.e. where
    an index appears on one tensor and nowhere else.
Take inputs and parse for single term index operations i . e . where an index appears on one tensor and nowhere else .
def _dp_parse_out_single_term_ops(
    inputs: List[FrozenSet[int]], all_inds: Tuple[str, ...], ind_counts: CounterType[str]
) -> Tuple[List[FrozenSet[int]], List[Tuple[int]], List[Union[int, Tuple[int]]]]:
    """Take `inputs` and parse for single term index operations, i.e. where
    an index appears on one tensor and nowhere else.

    If a term is completely reduced to a scalar in this way it can be removed
    to `inputs_done`. If only some indices can be summed then add a 'single
    term contraction' that will perform this summation.
    """
    i_single = frozenset(i for i, c in enumerate(all_inds) if ind_counts[c] == 1)
    inputs_parsed: List[FrozenSet[int]] = []
    inputs_done: List[Tuple[int]] = []
    inputs_contractions: List[Union[int, Tuple[int]]] = []
    for j, i in enumerate(inputs):
        i_reduced = i - i_single
        if (not i_reduced) and (len(i) > 0):
            # input reduced to scalar already - remove
            inputs_done.append((j,))
        else:
            # if the input has any index reductions, add single contraction
            inputs_parsed.append(i_reduced)
            inputs_contractions.append((j,) if i_reduced != i else j)

    return inputs_parsed, inputs_done, inputs_contractions
def _dp_parse_out_single_term_ops ( inputs : List [ FrozenSet [ int ] ] , all_inds : Tuple [ str , ... ] , ind_counts : CounterType [ str ] ) -> Tuple [ List [ FrozenSet [ int ] ] , List [ Tuple [ int ] ] , List [ Union [ int , Tuple [ int ] ] ] ] : i_single = frozenset ( i for i , c in enumerate ( all_inds ) if ind_counts [ c ] == 1 ) inputs_parsed : List [ FrozenSet [ int ] ] = [ ] inputs_done : List [ Tuple [ int ] ] = [ ] inputs_contractions : List [ Union [ int , Tuple [ int ] ] ] = [ ] for j , i in enumerate ( inputs ) : i_reduced = i - i_single if ( not i_reduced ) and ( len ( i ) > 0 ) : # input reduced to scalar already - remove inputs_done . append ( ( j , ) ) else : # if the input has any index reductions, add single contraction inputs_parsed . append ( i_reduced ) inputs_contractions . append ( ( j , ) if i_reduced != i else j ) return inputs_parsed , inputs_done , inputs_contractions