code: def _clone_metrics(metrics):
      """Creates a copy of the maybe-nested metric specification.
  
      Args:
        metrics: A collection of metric specifications. Supports the same set of
          formats as the `metrics` argument in `tf.keras.Model.compile`.
  
      Returns:
        The same format as the `metrics` argument, with all `tf.keras.metric.Metric`
        objects replaced by their copies.
      """
  
      def clone(metric):
          # A `Metric` object is stateful and can only be used in 1 model on 1 output.
          # Cloning the object allows the same metric to be applied in both base and
          # adversarial-regularized models, and also on multiple outputs in one model.
          # The cloning logic is the same as the `clone_metric` function in
          # https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/metrics.py
          if not isinstance(metric, tf.keras.metrics.Metric):
              return metric
          with tf.init_scope():
              return metric.__class__.from_config(metric.get_config())
  
      return tf.nest.map_structure(clone, metrics)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import functools
  import types
  import attr
  import neural_structured_learning.configs
  from neural_structured_learning.lib import adversarial_neighbor
  import six
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: _clone_metrics(metrics) and returns: tf, metric, metric