<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert(self, state, token):
 """change internal state, return action"""

        if token == EndSymbol():
            return self[state][EndSymbol()]
        from pydsl.check import check
        symbol_list = [x for x in self[state] if isinstance(x, TerminalSymbol) and check(x.gd, [token])]
        if not symbol_list:
            return {"action":"Fail"}
        if len(symbol_list) > 1:
            raise Exception("Multiple symbols matches input")
        symbol = symbol_list[0]
        return self[state][symbol]