<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def randchoice(seq: Union[str, list, tuple, dict, set]) -> any: """Return a randomly chosen element from the given sequence. Raises TypeError if *seq* is not str, list, tuple, dict, set and an IndexError if it is empty. 'a' """

    if not isinstance(seq, (str, list, tuple, dict, set)):
        raise TypeError('seq must be str, list, tuple, dict or set')
    if len(seq) <= 0:
        raise IndexError('seq must have at least one element')

    if isinstance(seq, set):
        values = list(seq)
        return randchoice(values)
    elif isinstance(seq, dict):
        indexes = list(seq)
        index = randchoice(indexes)
    else:
        index = randbelow(len(seq))

    return seq[index]