class_docstr: Provides a registry for saving objects.
docstr: Registers a Python object "candidate" for the given "name".
  
  Args:
    candidate: The candidate object to add to the registry.
    name: An optional string specifying the registry key for the candidate.
          If None, candidate.__name__ will be used.
  Raises:
    KeyError: If same name is used twice.
code: def register(self, candidate, name=None):
      """Registers a Python object "candidate" for the given "name".
  
      Args:
        candidate: The candidate object to add to the registry.
        name: An optional string specifying the registry key for the candidate.
              If None, candidate.__name__ will be used.
      Raises:
        KeyError: If same name is used twice.
      """
      if not name:
          name = candidate.__name__
      if name in self._registry:
          frame = self._registry[name][_LOCATION_TAG]
          raise KeyError(
              "Registering two %s with name '%s'! "
              "(Previous registration was in %s %s:%d)"
              % (
                  self._name,
                  name,
                  frame.name,
                  frame.filename,
                  frame.lineno,
              )
          )
  
      logging.vlog(
          1, "Registering %s (%s) in %s.", name, candidate, self._name
      )
      # stack trace is [this_function, Register(), user_function,...]
      # so the user function is #2.
      stack = traceback.extract_stack(limit=3)
      stack_index = min(2, len(stack) - 1)
      if stack_index >= 0:
          location_tag = stack[stack_index]
      else:
          location_tag = (
              "UNKNOWN",
              "UNKNOWN",
              "UNKNOWN",
              "UNKNOWN",
              "UNKNOWN",
          )
      self._registry[name] = {
          _TYPE_TAG: candidate,
          _LOCATION_TAG: location_tag,
      }
  
file_path: tensorflow-upstream/tensorflow/python/framework/registry.py
imports: import traceback
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import compat
label_desc: Use image node_id 2 for calling the Registry obj's underlying member method code with example usage: obj.register(candidate, name) without return types