code: def create_num_parameters_metric_fn(tower_name=None):
      """Makes the function to count the number of trainable parameters.
  
      Args:
        tower_name: The name of the tower that contains variables we want to count.
          If it is None, then use all variables.
  
      Returns:
        A function that returns a dict with a single string key `num_parameters`
        that maps to a tuple containing two int32 0-D Tensors, both containing the
        number of trainable parameters.
      """
  
      def _metric_fn(labels, predictions, weights=None):
          """Counts the number of trainable parameters.
  
          Args:
            labels: Unused.
            predictions: Unused.
            weights: Unused.
  
          Returns:
            dict with a single string key `num_parameters` that maps to a tuple
            containing two int32 0-D Tensors, both containing the number of trainable
            parameters.
          """
  
          del labels  # unused
          del predictions  # unused
          del weights  # unused
  
          trainable = tf.compat.v1.trainable_variables()
          if tower_name:
              counted_variables = [
                  var
                  for var in trainable
                  if var.name.startswith(
                      "Phoenix/{}".format(tower_name)
                  )
              ]
          else:
              counted_variables = trainable
  
          if counted_variables:
              parameters = tf.add_n(
                  [tf.size(input=var) for var in counted_variables]
              )
          else:
              parameters = tf.constant(0, dtype=tf.int32)
  
          return {"num_parameters": (parameters, parameters)}
  
      return _metric_fn
  
imports: from absl import logging
  import tensorflow.compat.v2
label_desc: Use image node_id 5 for calling a global function with example usage: create_num_parameters_metric_fn(tower_name) and returns: _metric_fn, dict