docs: def _dump(config_instance, dict_type=OrderedDict):
      """ Dumps an instance from ``instance`` to a dictionary type mapping.
  
      :param object instance: The instance to serialized to a dictionary
      :param object dict_type: Some dictionary type, defaults to ``OrderedDict``
      :return: Dumped dictionary
      :rtype: collections.OrderedDict (or instance of ``dict_type``)
      """
  
      if not is_config(config_instance):
          raise ValueError(
              f"cannot dump instance {config_instance!r} to dict, "
              "instance is not a config class"
          )
  
      result = dict_type()
      for var in attr.fields(config_instance.__class__):
          if not is_config_var(var):
              continue
  
          entry = var.metadata[CONFIG_KEY]
          dump_key = entry.name if entry.name else var.name
          dump_default = var.default if var.default else None
  
          if callable(entry.encoder):
              result[dump_key] = entry.encoder(
                  getattr(config_instance, var.name, dump_default)
              )
              continue
  
          if is_array_type(entry.type):
              items = getattr(config_instance, var.name, [])
              if items is not None:
                  result[dump_key] = [
                      (_dump(item, dict_type=dict_type) if is_config(item) else item)
                      for item in items
                  ]
          elif is_enum_type(entry.type):
              dump_value = getattr(config_instance, var.name, dump_default)
              result[dump_key] = (
                  dump_value.value if dump_value in entry.type else dump_value
              )
          elif is_bytes_type(entry.type):
              result[dump_key] = encode_bytes(
                  getattr(config_instance, var.name, dump_default)
              )
          else:
              if is_config_type(entry.type):
                  result[dump_key] = _dump(
                      getattr(config_instance, var.name, {}), dict_type=dict_type
                  )
              else:
                  dump_value = getattr(config_instance, var.name, dump_default)
                  if is_object_type(type(dump_value)):
                      dump_value = {
                          key: (
                              _dump(value, dict_type=dict_type)
                              if is_config(value)
                              else value
                          )
                          for (key, value) in dump_value.items()
                      }
  
                  if dump_value is not None:
                      result[dump_key] = dump_value
  
      return result