code: def assert_is_valid_key(key):
      
      if SETTINGS.CONFIG.ENFORCE_KEYS_MONGO_COMPATIBLE and (
              isinstance(key, basestring) and ('.' in key or key[0] == '$')):
          raise KeyError('Invalid key "{}". Config-keys cannot '
                         'contain "." or start with "$"'.format(key))
  
      if SETTINGS.CONFIG.ENFORCE_KEYS_JSONPICKLE_COMPATIBLE and \
              isinstance(key, basestring) and (
              key in jsonpickle.tags.RESERVED or key.startswith('json://')):
          raise KeyError('Invalid key "{}". Config-keys cannot be one of the'
                         'reserved jsonpickle tags: {}'
                         .format(key, jsonpickle.tags.RESERVED))
  
      if SETTINGS.CONFIG.ENFORCE_STRING_KEYS and (
              not isinstance(key, basestring)):
          raise KeyError('Invalid key "{}". Config-keys have to be strings, '
                         'but was {}'.format(key, type(key)))
  
      if SETTINGS.CONFIG.ENFORCE_VALID_PYTHON_IDENTIFIER_KEYS and (
              isinstance(key, basestring) and not PYTHON_IDENTIFIER.match(key)):
          raise KeyError('Key "{}" is not a valid python identifier'
                         .format(key))
  
      if SETTINGS.CONFIG.ENFORCE_KEYS_NO_EQUALS and (
              isinstance(key, basestring) and '=' in key):
          raise KeyError('Invalid key "{}". Config keys may not contain an'
                         'equals sign ("=").'.format('='))
docs: Raise KeyError if a given config key violates any requirements.
  
      The requirements are the following and can be individually deactivated
      in ``sacred.SETTINGS.CONFIG_KEYS``:
        * ENFORCE_MONGO_COMPATIBLE (default: True):
          make sure the keys don't contain a '.' or start with a '$'
        * ENFORCE_JSONPICKLE_COMPATIBLE (default: True):
          make sure the keys do not contain any reserved jsonpickle tags
          This is very important. Only deactivate if you know what you are doing.
        * ENFORCE_STRING (default: False):
          make sure all keys are string.
        * ENFORCE_VALID_PYTHON_IDENTIFIER (default: False):
          make sure all keys are valid python identifiers.
  
      Parameters
      ----------
      key:
        The key that should be checked
  
      Raises
      ------
      KeyError:
        if the key violates any requirements