code: def _copy_layer(layer):
      """Create a copy of a Keras layer with identical parameters.
  
      The new layer will not share weights with the old one.
  
      Args:
        layer: An instance of `tf.keras.layers.Layer`.
  
      Returns:
        A new keras layer.
  
      Raises:
        TypeError: If `layer` is not a keras layer.
        ValueError: If `layer` cannot be correctly cloned.
      """
      if not isinstance(layer, tf.keras.layers.Layer):
          raise TypeError("layer is not a keras layer: %s" % str(layer))
  
      # pylint:disable=unidiomatic-typecheck
      if type(layer) == tf.compat.v1.keras.layers.DenseFeatures:
          raise ValueError(
              "DenseFeatures V1 is not supported. "
              "Use tf.compat.v2.keras.layers.DenseFeatures instead."
          )
      if layer.built:
          logging.warning(
              "Beware: Copying a layer that has already been built: '%s'.  "
              "This can lead to subtle bugs because the original layer's weights "
              "will not be used in the copy.",
              layer.name,
          )
      # Get a fresh copy so we don't modify an incoming layer in place.  Weights
      # will not be shared.
      return type(layer).from_config(layer.get_config())
  
file_path: agents/tf_agents/networks/encoding_network.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl import logging
  import gin
  from six.moves import zip
  import tensorflow
  from tf_agents.keras_layers import permanent_variable_rate_dropout
  from tf_agents.networks import network
  from tf_agents.networks import utils
  from tf_agents.utils import nest_utils
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 for calling a global function with example usage: _copy_layer(layer) and returns: type