code: def check_options(options, valid_options):
      """Check if an option (required or optional) is valid. i.e. in the list of valid options.
  
      Parameters
      ----------
      options: dict
          dict indexed by option name of options and options values to be checked.
  
      valid_options: list of dict
          list of all valid options and choices for a platform.
  
      Returns
      -------
      None. Raise TVMCException if check fails, i.e. if an option is not in the list of valid options.
  
      """
      required_options = [
          opt["name"] for opt in valid_options if opt["required"]
      ]
      for required_option in required_options:
          if required_option not in options:
              raise TVMCException(
                  f"Option '{required_option}' is required but was not specified. Use --list-options "
                  "to see all required options."
              )
  
      remaining_options = set(options) - set(required_options)
      optional_options = [
          opt["name"] for opt in valid_options if not opt["required"]
      ]
      for option in remaining_options:
          if option not in optional_options:
              raise TVMCException(
                  f"Option '{option}' is invalid. Use --list-options to see all available options."
              )
  
file_path: tvm/python/tvm/driver/tvmc/project.py
imports: import os
  import pathlib
  from collections import defaultdict
  from typing import Union
  from .None import TVMCException
  from .fmtopt import format_option
label_desc: Use image node_id 3 for calling a global function with example usage: check_options(options, valid_options) without return types