code: def get_computed_and_true_norms_from_model(
      model: tf.keras.Model,
      per_example_loss_fn: Optional[
          Callable[[tf.Tensor, tf.Tensor], tf.Tensor]
      ],
      num_microbatches: Optional[int],
      x_batch: tf.Tensor,
      weight_batch: Optional[tf.Tensor] = None,
      rng_seed: int = 777,
      registry: layer_registry.LayerRegistry = None,
      partial: bool = False,
  ):
      """Generates relevant norms from an input model and other specs."""
      trainable_vars = None
      if partial:
          # Gets the first layer with variables.
          for l in model.layers:
              trainable_vars = l.trainable_variables
              if trainable_vars:
                  break
      y_pred = model(x_batch)
      y_batch = tf.ones_like(y_pred)
      tf.keras.utils.set_random_seed(rng_seed)
      computed_norms = clip_grads.compute_gradient_norms(
          input_model=model,
          x_batch=x_batch,
          y_batch=y_batch,
          weight_batch=weight_batch,
          layer_registry=registry,
          per_example_loss_fn=per_example_loss_fn,
          num_microbatches=num_microbatches,
          trainable_vars=trainable_vars,
      )
      tf.keras.utils.set_random_seed(rng_seed)
      true_norms = compute_true_gradient_norms(
          input_model=model,
          x_batch=x_batch,
          y_batch=y_batch,
          weight_batch=weight_batch,
          per_example_loss_fn=per_example_loss_fn,
          num_microbatches=num_microbatches,
          trainable_vars=trainable_vars,
      )
      return computed_norms, true_norms
  
imports: from collections.abc import Callable, MutableSequence, Sequence
  from typing import Optional
  import numpy
  import tensorflow
  import tensorflow.compat.v2
  from tensorflow_privacy.privacy.fast_gradient_clipping import clip_grads
  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 7 for calling a global function with example usage: get_computed_and_true_norms_from_model(model, per_example_loss_fn, num_microbatches, x_batch, weight_batch, rng_seed, registry, partial) and returns: computed_norms,  true_norms