def to_dict(self, namespace_prefix: Text = "") -> Dict[Text, JsonAtomicValue]:
    """Serializes this instance to a Python dictionary."""
    assert not namespace_prefix or namespace_prefix.endswith(".")

    output = dict()
    for key in self._field_names:
      value = getattr(self, key)
      if isinstance(value, Config):
        child_dict = value.to_dict(
            namespace_prefix=(namespace_prefix + key + "."))
        output.update(child_dict)
      else:
        output[namespace_prefix + key] = value
    return output
Serializes this instance to a Python dictionary.
language/canine/config_utils.py