from typing import Optional
from typing import List


def get_pairs(input_list: list, exclude_same: bool = True, forward_only: bool = True, prefix: Optional[str] = None)\
        -> List[tuple]:
    """
    Pair-ify :attr:`input_string` be returning a list of tuples containing pairs of items from list.
    :param input_list: the input list
    :param exclude_same: if True, will exclude (item, item) tuples from paired output list
    :param forward_only: if True, will exclude associative pairs
    :param prefix: prefix applied
    :return: a list of pairs (tuples)
    """
    paired_list = []
    for item1 in input_list:
        for item2 in input_list:
            if item1 == item2 and exclude_same:
                continue

            item1_prefixed = (prefix or '') + item1
            item2_prefixed = (prefix or '') + item2
            if (item2_prefixed, item1_prefixed) in paired_list and forward_only:
                continue
            paired_list.append((item1_prefixed, item2_prefixed))
    return paired_list