class_docstr: Dict-like class for managing function registrations.
  
  ```python
  my_registry = Registry("custom_name")
  
  @my_registry.register
  def my_func():
    pass
  
  @my_registry.register()
  def another_func():
    pass
  
  @my_registry.register("non_default_name")
  def third_func(x, y, z):
    pass
  
  def foo():
    pass
  
  my_registry.register()(foo)
  my_registry.register("baz")(lambda (x, y): x + y)
  my_register.register("bar")
  
  print(list(my_registry))
  # ["my_func", "another_func", "non_default_name", "foo", "baz"]
  # (order may vary)
  print(my_registry["non_default_name"] is third_func)  # True
  print("third_func" in my_registry)                    # False
  print("bar" in my_registry)                           # False
  my_registry["non-existent_key"]                       # raises KeyError
  ```
  
  Optional validation, on_set callback and value transform also supported.
  See `__init__` doc.
class_docstr_tok: ["Dict-like","class","for","managing","function","registrations",".","``","`","python","my_registry","=","Registry","(","``","custom_name","''",")","@","my_registry.register","def","my_func","(",")",":","pass","@","my_registry.register","(",")","def","another_func","(",")",":","pass","@","my_registry.register","(","``","non_default_name","''",")","def","third_func","(","x",",","y",",","z",")",":","pass","def","foo","(",")",":","pass","my_registry.register","(",")","(","foo",")","my_registry.register","(","``","baz","''",")","(","lambda","(","x",",","y",")",":","x","+","y",")","my_register.register","(","``","bar","''",")","print","(","list","(","my_registry",")",")","#","[","``","my_func","''",",","``","another_func","''",",","``","non_default_name","''",",","``","foo","''",",","``","baz","''","]","#","(","order","may","vary",")","print","(","my_registry","[","``","non_default_name","''","]","is","third_func",")","#","True","print","(","``","third_func","''","in","my_registry",")","#","False","print","(","``","bar","''","in","my_registry",")","#","False","my_registry","[","``","non-existent_key","''","]","#","raises","KeyError","``","`","Optional","validation",",","on_set","callback","and","value","transform","also","supported",".","See","`","__init__","`","doc","."]
docstr: Construct a new registry.
  
  Args:
    registry_name: str identifier for the given registry. Used in error msgs.
    default_key_fn (optional): function mapping value -> key for registration
      when a key is not provided
    validator (optional): if given, this is run before setting a given (key,
      value) pair. Accepts (key, value) and should raise if there is a
      problem. Overwriting existing keys is not allowed and is checked
      separately. Values are also checked to be callable separately.
    on_set (optional): callback function accepting (key, value) pair which is
      run after an item is successfully set.
    value_transformer (optional): if run, `__getitem__` will return
      value_transformer(key, registered_value).
code: def __init__(
      self,
      registry_name,
      default_key_fn=default_name,
      validator=None,
      on_set=None,
      value_transformer=(lambda k, v: v),
  ):
      """Construct a new registry.
  
      Args:
        registry_name: str identifier for the given registry. Used in error msgs.
        default_key_fn (optional): function mapping value -> key for registration
          when a key is not provided
        validator (optional): if given, this is run before setting a given (key,
          value) pair. Accepts (key, value) and should raise if there is a
          problem. Overwriting existing keys is not allowed and is checked
          separately. Values are also checked to be callable separately.
        on_set (optional): callback function accepting (key, value) pair which is
          run after an item is successfully set.
        value_transformer (optional): if run, `__getitem__` will return
          value_transformer(key, registered_value).
      """
      self._registry = {}
      self._name = registry_name
      self._default_key_fn = default_key_fn
      self._validator = validator
      self._on_set = on_set
      self._value_transformer = value_transformer
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from tensor2tensor.utils import misc_utils
  import tensorflow.compat.v1
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 1 to create a new Registry object from inherited base classes: object with example: obj = Registry(registry_name, default_key_fn, validator, on_set, value_transformer)