code: def validate_targets(parse_targets, additional_target_options=None):
      """
      Apply a series of validations in the targets provided via CLI.
      """
      tvm_target_kinds = tvm.target.Target.list_kinds()
      targets = [t["name"] for t in parse_targets]
  
      if len(targets) > len(set(targets)):
          raise TVMCException(
              "Duplicate target definitions are not allowed"
          )
  
      if targets[-1] not in tvm_target_kinds:
          tvm_target_names = ", ".join(tvm_target_kinds)
          raise TVMCException(
              f"The last target needs to be a TVM target. Choices: {tvm_target_names}"
          )
  
      tvm_targets = [t for t in targets if t in _valid_target_kinds()]
      if len(tvm_targets) > 2:
          verbose_tvm_targets = ", ".join(tvm_targets)
          raise TVMCException(
              "Only two of the following targets can be used at a time. "
              f"Found: {verbose_tvm_targets}."
          )
  
      if additional_target_options is not None:
          for target_name in additional_target_options:
              if not any(
                  [
                      target
                      for target in parse_targets
                      if target["name"] == target_name
                  ]
              ):
                  first_option = list(
                      additional_target_options[target_name].keys()
                  )[0]
                  raise TVMCException(
                      f"Passed --target-{target_name}-{first_option}"
                      f" but did not specify {target_name} target"
                  )
  
imports: import os
  import logging
  import json
  import re
  import tvm
  from tvm.driver import tvmc
  from tvm.driver.tvmc import TVMCException
  from tvm.driver.tvmc.composite_target import get_codegen_by_target, get_codegen_names
  from tvm.ir.attrs import make_node, _ffi_api
  from tvm.ir.transform import PassContext
  from tvm.target import Target, TargetKind
label_desc: Use image node_id 8 for calling a global function with example usage: validate_targets(parse_targets, additional_target_options) without return types