class_docstr: Any class that inherits from `Registrable` gains access to a named registry for its
  subclasses. To register them, just decorate them with the classmethod
  `@BaseClass.register(name)`.
  
  After which you can call `BaseClass.list_available()` to get the keys for the
  registered subclasses, and `BaseClass.by_name(name)` to get the corresponding subclass.
  Note that the registry stores the subclasses themselves; not class instances.
  In most cases you would then call `from_params(params)` on the returned subclass.
  
  You can specify a default by setting `BaseClass.default_implementation`.
  If it is set, it will be the first element of `list_available()`.
  
  Note that if you use this class to implement a new `Registrable` abstract class,
  you must ensure that all subclasses of the abstract class are loaded when the module is
  loaded, because the subclasses register themselves in their respective files. You can
  achieve this by having the abstract class and all subclasses in the __init__.py of the
  module in which they reside (as this causes any import of either the abstract class or
  a subclass to load all other subclasses and the abstract class).
class_docstr_tok: ["Any","class","that","inherits","from","`","Registrable","`","gains","access","to","a","named","registry","for","its","subclasses",".","To","register","them",",","just","decorate","them","with","the","classmethod","`","@","BaseClass.register","(","name",")","`",".","After","which","you","can","call","`","BaseClass.list_available","(",")","`","to","get","the","keys","for","the","registered","subclasses",",","and","`","BaseClass.by_name","(","name",")","`","to","get","the","corresponding","subclass",".","Note","that","the","registry","stores","the","subclasses","themselves",";","not","class","instances",".","In","most","cases","you","would","then","call","`","from_params","(","params",")","`","on","the","returned","subclass",".","You","can","specify","a","default","by","setting","`","BaseClass.default_implementation","`",".","If","it","is","set",",","it","will","be","the","first","element","of","`","list_available","(",")","`",".","Note","that","if","you","use","this","class","to","implement","a","new","`","Registrable","`","abstract","class",",","you","must","ensure","that","all","subclasses","of","the","abstract","class","are","loaded","when","the","module","is","loaded",",","because","the","subclasses","register","themselves","in","their","respective","files",".","You","can","achieve","this","by","having","the","abstract","class","and","all","subclasses","in","the","__init__.py","of","the","module","in","which","they","reside","(","as","this","causes","any","import","of","either","the","abstract","class","or","a","subclass","to","load","all","other","subclasses","and","the","abstract","class",")","."]
docstr: Default behavior to get a params dictionary from a registrable class
  that does NOT have a _to_params implementation. It is NOT recommended to
   use this method. Rather this method is a minial implementation that
   exists so that calling `_to_params` does not break.
  
  # Returns
  
  parameter_dict: `Dict[str, Any]`
      A minimal parameter dictionary for a given registrable class. Will
      get the registered name and return that as well as any positional
      arguments it can find the value of.
docstr_tok: ["Default","behavior","to","get","a","params","dictionary","from","a","registrable","class","that","does","NOT","have","a","_to_params","implementation",".","It","is","NOT","recommended","to","use","this","method",".","Rather","this","method","is","a","minial","implementation","that","exists","so","that","calling","`","_to_params","`","does","not","break",".","#","Returns","parameter_dict",":","`","Dict","[","str",",","Any","]","`","A","minimal","parameter","dictionary","for","a","given","registrable","class",".","Will","get","the","registered","name","and","return","that","as","well","as","any","positional","arguments","it","can","find","the","value","of","."]
code: def _to_params(self) -> Dict[str, Any]:
      """
      Default behavior to get a params dictionary from a registrable class
      that does NOT have a _to_params implementation. It is NOT recommended to
       use this method. Rather this method is a minial implementation that
       exists so that calling `_to_params` does not break.
  
      # Returns
  
      parameter_dict: `Dict[str, Any]`
          A minimal parameter dictionary for a given registrable class. Will
          get the registered name and return that as well as any positional
          arguments it can find the value of.
  
      """
      logger.warning(
          f"'{self.__class__.__name__}' does not implement '_to_params`. Will"
          f" use Registrable's `_to_params`."
      )
  
      # Get the list of parent classes in the MRO in order to check where to
      # look for the registered name. Skip the first because that is the
      # current class.
      mro = inspect.getmro(self.__class__)[1:]
  
      registered_name = None
      for parent in mro:
          # Check if Parent has any registered classes
          try:
              registered_classes = self._registry[parent]
          except KeyError:
              continue
  
          # Found a dict of (name,(class,constructor)) pairs. Check if the
          # current class is in it.
          for name, registered_value in registered_classes.items():
              registered_class, _ = registered_value
              if registered_class == self.__class__:
                  registered_name = name
                  break
  
          # Extra break to end the top loop.
          if registered_name is not None:
              break
  
      if registered_name is None:
          raise KeyError(
              f"'{self.__class__.__name__}' is not registered"
          )
  
      parameter_dict = {"type": registered_name}
  
      # Get the parameters from the init function.
      for parameter in inspect.signature(
          self.__class__
      ).parameters.values():
          # Skip non-positional arguments. For simplicity, these are arguments
          # without a default value as those will be required for the
          # `from_params` method.
          if parameter.default != inspect.Parameter.empty:
              logger.debug(f"Skipping parameter {parameter.name}")
              continue
  
          # Try to get the value of the parameter from the class. Will only
          # try 'name' and '_name'. If it is not there, the parameter is not
          # added to the returned dict.
          if hasattr(self, parameter.name):
              parameter_dict[parameter.name] = getattr(
                  self, parameter.name
              )
          elif hasattr(self, f"_{parameter.name}"):
              parameter_dict[parameter.name] = getattr(
                  self, f"_{parameter.name}"
              )
          else:
              logger.warning(
                  f"Could not find a value for positional argument {parameter.name}"
              )
              continue
  
      return parameter_dict
  
file_path: allennlp/allennlp/common/registrable.py
imports: import importlib
  import logging
  import inspect
  from collections import defaultdict
  from typing import Callable, ClassVar, DefaultDict, Dict, List, Optional, Tuple, Type, TypeVar, cast, Any
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.from_params import FromParams
label_desc: Use image node_id 5 for calling the Registrable obj's underlying member method code with example usage: obj._to_params() and returns: parameter_dict