class_docstr: Mixin to give a from_params method to classes. We create a distinct base class for this
  because sometimes we want non-Registrable classes to be instantiatable from_params.
class_docstr_tok: ["Mixin","to","give","a","from_params","method","to","classes",".","We","create","a","distinct","base","class","for","this","because","sometimes","we","want","non-Registrable","classes","to","be","instantiatable","from_params","."]
docstr: Returns a `Params` object that can be used with `.from_params()` to recreate an
  object just like it.
  
  This relies on `_to_params()`. If you need this in your custom `FromParams` class,
  override `_to_params()`, not this method.
docstr_tok: ["Returns","a","`","Params","`","object","that","can","be","used","with","`",".from_params","(",")","`","to","recreate","an","object","just","like","it",".","This","relies","on","`","_to_params","(",")","`",".","If","you","need","this","in","your","custom","`","FromParams","`","class",",","override","`","_to_params","(",")","`",",","not","this","method","."]
code: def to_params(self) -> Params:
      """
      Returns a `Params` object that can be used with `.from_params()` to recreate an
      object just like it.
  
      This relies on `_to_params()`. If you need this in your custom `FromParams` class,
      override `_to_params()`, not this method.
      """
  
      def replace_object_with_params(o: Any) -> Any:
          if isinstance(o, FromParams):
              return o.to_params()
          elif isinstance(o, List):
              return [replace_object_with_params(i) for i in o]
          elif isinstance(o, Set):
              return {replace_object_with_params(i) for i in o}
          elif isinstance(o, Dict):
              return {
                  key: replace_object_with_params(value)
                  for key, value in o.items()
              }
          else:
              return o
  
      return Params(replace_object_with_params(self._to_params()))
  
imports: import collections.abc
  from copy import deepcopy
  from pathlib import Path
  from typing import Any, Callable, cast, Dict, Iterable, List, Mapping, Set, Tuple, Type, TypeVar, Union, Optional
  import inspect
  import logging
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.lazy import Lazy
  from allennlp.common.params import Params
label_desc: Use image node_id 2 for calling the FromParams obj's underlying member method code with example usage: obj.to_params() and returns: Params, o, unknown, unknown, unknown, o