code: def get_registry_generator_fn(
      tape: tf.GradientTape,
      layer_registry: lr.LayerRegistry,
      num_microbatches: Optional[type_aliases.BatchSize] = None,
  ):
      """Creates the generator function for `compute_gradient_norms()`."""
      if layer_registry is None:
          # Needed for backwards compatibility.
          registry_generator_fn = None
      else:
  
          def registry_generator_fn(layer_instance, args, kwargs):
              if layer_instance.trainable_variables:
                  # Only trainable variables factor into the gradient.
                  if not layer_registry.is_elem(layer_instance):
                      raise NotImplementedError(
                          "Layer %s is not in the registry of known layers that can "
                          "be used for efficient gradient clipping."
                          % layer_instance.__class__.__name__
                      )
                  registry_fn = layer_registry.lookup(layer_instance)
                  (
                      layer_vars,
                      layer_outputs,
                      layer_sqr_norm_fn,
                  ) = registry_fn(
                      layer_instance,
                      args,
                      kwargs,
                      tape,
                      num_microbatches,
                  )
                  return layer_outputs, (
                      layer_vars,
                      layer_sqr_norm_fn,
                      layer_instance.trainable_weights,
                  )
              else:
                  # Non-trainable layer.
                  return layer_instance(*args, **kwargs), None
  
      return registry_generator_fn
  
file_path: privacy/tensorflow_privacy/privacy/fast_gradient_clipping/clip_grads.py
imports: from collections.abc import Sequence
  from typing import Optional
  import tensorflow
  from tensorflow_privacy.privacy.fast_gradient_clipping import common_manip_utils
  from tensorflow_privacy.privacy.fast_gradient_clipping import gradient_clipping_utils
  from tensorflow_privacy.privacy.fast_gradient_clipping import layer_registry
  from tensorflow_privacy.privacy.fast_gradient_clipping import type_aliases
label_desc: Use image node_id 1 for calling a global function with example usage: get_registry_generator_fn(tape, layer_registry, num_microbatches) and returns: registry_generator_fn, layer_outputs,  layer_vars,  layer_sqr_norm_fn,  layer_instance, layer_instance,  None