code: def check_type(token, ty, val):
      def matches(tok: Token):
          return tok.name == ty and (val is None or tok.value == val)
  
      if ty is None:
          return True
  
      if isinstance(ty, str):
          return matches(token)
  
      if isinstance(ty, list):
          return any(map(matches, token))
  
      return False
  
imports: import re
  from dataclasses import dataclass, InitVar, field
  from itertools import chain
  from typing import Any, Dict, List, Union, Optional, ClassVar
  import numpy
  from toolz import valfilter, valmap
label_desc: Use image node_id 2 for calling a global function with example usage: check_type(token, ty, val) and returns: False, unknown, True, matches, any