code: def get_bool_opt(options, optname, default=None):
      string = options.get(optname, default)
      if isinstance(string, bool):
          return string
      elif isinstance(string, int):
          return bool(string)
      elif not isinstance(string, string_types):
          raise OptionError(
              "Invalid type %r for option %s; use "
              "1/0, yes/no, true/false, on/off" % (string, optname)
          )
      elif string.lower() in ("1", "yes", "true", "on"):
          return True
      elif string.lower() in ("0", "no", "false", "off"):
          return False
      else:
          raise OptionError(
              "Invalid value %r for option %s; use "
              "1/0, yes/no, true/false, on/off" % (string, optname)
          )
  
imports: import re
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: get_bool_opt(options, optname, default) and returns: string, bool, True, False