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: Decorator to register a function, or registration itself.
  
  This is primarily intended for use as a decorator, either with or without
  a key/parentheses.
  ```python
  @my_registry.register('key1')
  def value_fn(x, y, z):
    pass
  
  @my_registry.register()
  def another_fn(x, y):
    pass
  
  @my_registry.register
  def third_func():
    pass
  ```
  
  Note if key_or_value is provided as a non-callable, registration only
  occurs once the returned callback is called with a callable as its only
  argument.
  ```python
  callback = my_registry.register('different_key')
  'different_key' in my_registry  # False
  callback(lambda (x, y): x + y)
  'different_key' in my_registry  # True
  ```
  
  Args:
    key_or_value (optional): key to access the registered value with, or the
      function itself. If `None` (default), `self.default_key` will be called
      on `value` once the returned callback is called with `value` as the only
      arg. If `key_or_value` is itself callable, it is assumed to be the value
      and the key is given by `self.default_key(key)`.
  
  Returns:
    decorated callback, or callback generated a decorated function.
code: def register(self, key_or_value=None):
      """Decorator to register a function, or registration itself.
  
      This is primarily intended for use as a decorator, either with or without
      a key/parentheses.
      ```python
      @my_registry.register('key1')
      def value_fn(x, y, z):
        pass
  
      @my_registry.register()
      def another_fn(x, y):
        pass
  
      @my_registry.register
      def third_func():
        pass
      ```
  
      Note if key_or_value is provided as a non-callable, registration only
      occurs once the returned callback is called with a callable as its only
      argument.
      ```python
      callback = my_registry.register('different_key')
      'different_key' in my_registry  # False
      callback(lambda (x, y): x + y)
      'different_key' in my_registry  # True
      ```
  
      Args:
        key_or_value (optional): key to access the registered value with, or the
          function itself. If `None` (default), `self.default_key` will be called
          on `value` once the returned callback is called with `value` as the only
          arg. If `key_or_value` is itself callable, it is assumed to be the value
          and the key is given by `self.default_key(key)`.
  
      Returns:
        decorated callback, or callback generated a decorated function.
      """
  
      def decorator(value, key):
          self[key] = value
          return value
  
      # Handle if decorator was used without parens
      if callable(key_or_value):
          return decorator(value=key_or_value, key=None)
      else:
          return lambda value: decorator(value, key=key_or_value)
  
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 7 for calling the Registry obj's underlying member method code with example usage: obj.register(key_or_value) and returns: value, decorator, function