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: Returns a callable function that constructs an argument of the registered class.  Because
  you can register particular functions as constructors for specific names, this isn't
  necessarily the `__init__` method of some class.
docstr_tok: ["Returns","a","callable","function","that","constructs","an","argument","of","the","registered","class",".","Because","you","can","register","particular","functions","as","constructors","for","specific","names",",","this","isn't","necessarily","the","`","__init__","`","method","of","some","class","."]
code: def by_name(
      cls: Type[_RegistrableT], name: str
  ) -> Callable[..., _RegistrableT]:
      """
      Returns a callable function that constructs an argument of the registered class.  Because
      you can register particular functions as constructors for specific names, this isn't
      necessarily the `__init__` method of some class.
      """
      logger.debug(f"instantiating registered subclass {name} of {cls}")
      subclass, constructor = cls.resolve_class_name(name)
      if not constructor:
          return cast(Type[_RegistrableT], subclass)
      else:
          return cast(
              Callable[..., _RegistrableT],
              getattr(subclass, constructor),
          )
  
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 2 for calling the Registrable obj's underlying member method code with example usage: obj.by_name(cls, name) and returns: cast, cast