code: def _parse_config_options(
          config: Mapping[str, Union[ResourceOptions, Mapping[str, Any]]]=None):
      
  
      if config is None:
          return {}
  
      if not isinstance(config, collections.abc.Mapping):
          raise ValueError(
              "Config must be mapping, got '{}'".format(config))
  
      parsed = {}
  
      options_keys = {
          "allow_credentials", "expose_headers", "allow_headers", "max_age"
      }
  
      for origin, options in config.items():
          # TODO: check that all origins are properly formatted.
          # This is not a security issue, since origin is compared as strings.
          if not isinstance(origin, str):
              raise ValueError(
                  "Origin must be string, got '{}'".format(origin))
  
          if isinstance(options, ResourceOptions):
              resource_options = options
  
          else:
              if not isinstance(options, collections.abc.Mapping):
                  raise ValueError(
                      "Origin options must be either "
                      "aiohttp_cors.ResourceOptions instance or mapping, "
                      "got '{}'".format(options))
  
              unexpected_args = frozenset(options.keys()) - options_keys
              if unexpected_args:
                  raise ValueError(
                      "Unexpected keywords in resource options: {}".format(
                          # pylint: disable=bad-builtin
                          ",".join(map(str, unexpected_args))))
  
              resource_options = ResourceOptions(**options)
  
          parsed[origin] = resource_options
  
      return parsed
docs: Parse CORS configuration (default or per-route)
  
      :param config:
          Mapping from Origin to Resource configuration (allowed headers etc)
          defined either as mapping or `ResourceOptions` instance.
  
      Raises `ValueError` if configuration is not correct.