code: def _update_legacy_signature(signature):
      """Update a legacy name-mangled signature in-place.
  
      Note this code will not work if there are clashes between the old and new
      names, e.g. if x$dense_tensor$dense_tensor and x$dense_tensor are both
      features, but this is an edge case that we do not expect to ever happen.
  
      Args:
        signature: A SignatureDef.
      """
      for tensor_info_map in [signature.inputs, signature.outputs]:
          # It is necessary to make a copy of tensor_info_map.items() since we need to
          # modify tensor_info_map while iterating it.
          for original_name, original_tensor_info in list(
              tensor_info_map.items()
          ):
              match = _MANGLED_TENSOR_NAME_RE.match(original_name)
              if not match:
                  continue
              tf.compat.v1.logging.warn(
                  "Converting feature %s from legacy signature.  New models will "
                  "be written without name-mangling in the signature",
                  original_name,
              )
              name = match.group(1)
              if name == "dense_shape":
                  assert name not in tensor_info_map
              else:
                  assert (
                      name not in tensor_info_map
                      or tensor_info_map[name].WhichOneof("encoding")
                      == "coo_sparse"
                  )
              new_tensor_info = tensor_info_map[name]
              original_tensor_type = match.group(2)
              if original_tensor_type == "indices":
                  new_tensor_info.coo_sparse.indices_tensor_name = (
                      original_tensor_info.name
                  )
              elif original_tensor_type == "values":
                  new_tensor_info.dtype = original_tensor_info.dtype
                  new_tensor_info.coo_sparse.values_tensor_name = (
                      original_tensor_info.name
                  )
              elif original_tensor_type == "dense_shape":
                  new_tensor_info.coo_sparse.dense_shape_tensor_name = (
                      original_tensor_info.name
                  )
              else:
                  new_tensor_info.CopyFrom(
                      tensor_info_map[original_name]
                  )
              del tensor_info_map[original_name]
  
file_path: transform/tensorflow_transform/saved/saved_transform_io.py
imports: import importlib
  import os
  import re
  import tensorflow
  from tensorflow_transform.py_func import pyfunc_helper
  from tensorflow_transform.saved import constants
  from tensorflow_transform.saved import saved_model_loader
  from tensorflow.core.protobuf import struct_pb2
  from tensorflow.python.framework import ops
  from tensorflow.python.saved_model import nested_structure_coder
  from tensorflow.python.training import saver
label_desc: Use image node_id 1 for calling a global function with example usage: _update_legacy_signature(signature) without return types