code: def validate_compound_keys(m: ExpConf) -> ExpConf:
      """Check that:
  
      - all key are strings, which do not:
          contain spaces or consecutive commas
          contain commas unless inside a '[...]' compound key
          contain '[' unless at the beginning, and matched by a ']' at the end
          contain ']' unless at the end, and matched by a '[' at the beginning
          begin with '[' and end with ']' unless also containing a comma
      - all values are either boolean, strings, numbers or lists
      """
  
      def check_k(k):
          if not isinstance(k, str):
              raise argparse.ArgumentTypeError(
                  "Key '{}' is invalid! Keys must be strings.".format(k)
              )
  
          valid_re_str = "[^\s\,\]\[]+"
          list_re = re.compile(
              "\A({}|\[\s*({})(\s*,\s*{})*\s*\])\Z".format(
                  valid_re_str, valid_re_str, valid_re_str
              )
          )
  
          if list_re.match(k) is None:
              raise argparse.ArgumentTypeError(
                  "Key '{}' is invalid! Not a valid compound key.".format(
                      k
                  )
              )
  
      def check_v(v):
          types = [list, bool, str, int, float]
          if not any(map(lambda t: isinstance(v, t), types)):
              raise argparse.ArgumentTypeError(
                  "Value '{}' in the expanded \
      experiment config '{}' is invalid! Values must be strings, \
      lists, ints, floats or bools.".format(
                      v, m
                  )
              )
  
      def check_kv_compatibility(k, v):
          """For already validated k and v, check that
          if k is a compound key, the number of arguments in each sublist must match the
          number of arguments in k"""
  
          if k[0] == "[":
              n_args = len(k.strip("][").split(","))
              if not (isinstance(v, list)):
                  raise argparse.ArgumentTypeError(
                      "Key '{}' and value '{}' are incompatible: \
                  key is compound, but value is not.".format(
                          k, v
                      )
                  )
              else:
                  if isinstance(v[0], list):
                      for vi in v:
                          if len(vi) != n_args:
                              raise argparse.ArgumentTypeError(
                                  "Key '{}' and value '{}' have \
                                incompatible arities.".format(
                                      k, vi
                                  )
                              )
                  else:
                      if len(v) != n_args:
                          raise argparse.ArgumentTypeError(
                              "Key '{}' and value '{}' have \
                              incompatible arities.".format(
                                  k, v
                              )
                          )
  
      if isinstance(m, list):
          return [validate_compound_keys(i) for i in m]
  
      for k, v in m.items():
          check_k(k)
          check_v(v)
          check_kv_compatibility(k, v)
  
      return m
  
imports: from __future__ import absolute_import, division, print_function
  import argparse
  import itertools
  import re
  import sys
  from collections import ChainMap
  from typing import Any, Dict, List, Optional, Tuple, Union
  import commentjson
  import caliban.util
  import caliban.util.argparse
  import caliban.util.schema
label_desc: Use image node_id 9 for calling a global function with example usage: validate_compound_keys(m) and returns: m, unknown