code: def parse_target(target):
      """
      Parse a plain string of targets provided via a command-line
      argument.
  
      To send more than one codegen, a comma-separated list
      is expected. Options start with -<option_name>=<value>.
  
      We use python standard library 'shlex' to parse the argument in
      a POSIX compatible way, so that if options are defined as
      strings with spaces or commas, for example, this is considered
      and parsed accordingly.
  
  
      Example
      -------
  
      For the input `--target="foo -op1=v1 -op2="v ,2", bar -op3=v-4"` we
      should obtain:
  
        [
          {
              name: "foo",
              opts: {"op1":"v1", "op2":"v ,2"},
              raw: 'foo -op1=v1 -op2="v ,2"'
          },
          {
              name: "bar",
              opts: {"op3":"v-4"},
              raw: 'bar -op3=v-4'
          }
        ]
  
      Parameters
      ----------
      target : str
          Target options sent via CLI arguments
  
      Returns
      -------
      codegens : list of dict
          This list preserves the order in which codegens were
          provided via command line. Each Dict contains three keys:
          'name', containing the name of the codegen; 'opts' containing
          a key-value for all options passed via CLI; 'raw',
          containing the plain string for this codegen
      """
      codegen_names = tvmc.composite_target.get_codegen_names()
      codegens = []
  
      tvm_target_kinds = tvm.target.Target.list_kinds()
      parsed_tokens = tokenize_target(target)
  
      split_codegens = []
      current_codegen = []
      split_codegens.append(current_codegen)
      for token in parsed_tokens:
          # every time there is a comma separating
          # two codegen definitions, prepare for
          # a new codegen
          if token == ",":
              current_codegen = []
              split_codegens.append(current_codegen)
          else:
              # collect a new token for the current
              # codegen being parsed
              current_codegen.append(token)
  
      # at this point we have a list of lists,
      # each item on the first list is a codegen definition
      # in the comma-separated values
      for codegen_def in split_codegens:
          # the first is expected to be the name
          name = codegen_def[0]
          is_tvm_target = (
              name in tvm_target_kinds and name not in codegen_names
          )
          raw_target = " ".join(codegen_def)
          all_opts = codegen_def[1:] if len(codegen_def) > 1 else []
          opts = {}
          for opt in all_opts:
              try:
                  # deal with -- prefixed flags
                  if opt.startswith("--"):
                      opt_name = opt[2:]
                      opt_value = True
                  else:
                      opt = opt[1:] if opt.startswith("-") else opt
                      opt_name, opt_value = opt.split("=", maxsplit=1)
  
                      # remove quotes from the value: quotes are only parsed if they match,
                      # so it is safe to assume that if the string starts with quote, it ends
                      # with quote.
                      opt_value = (
                          opt_value[1:-1]
                          if opt_value[0] in ('"', "'")
                          else opt_value
                      )
              except ValueError:
                  raise ValueError(f"Error when parsing '{opt}'")
  
              opts[opt_name] = opt_value
  
          codegens.append(
              {
                  "name": name,
                  "opts": opts,
                  "raw": raw_target,
                  "is_tvm_target": is_tvm_target,
              }
          )
  
      return codegens
  
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 10 for calling a global function with example usage: parse_target(target) and returns: codegens