code: def get_choice_opt(
      options, optname, allowed, default=None, normcase=False
  ):
      """
      If the key `optname` from the dictionary is not in the sequence
      `allowed`, raise an error, otherwise return it.
      """
      string = options.get(optname, default)
      if normcase:
          string = string.lower()
      if string not in allowed:
          raise OptionError(
              "Value for option %s must be one of %s"
              % (optname, ", ".join(map(str, allowed)))
          )
      return string
  
imports: import re
  from io import TextIOWrapper
label_desc: Use image node_id 1 for calling a global function with example usage: get_choice_opt(options, optname, allowed, default, normcase) and returns: string