code: def _maybe_save_assets(write_fn, assets_to_add=None):
      """Saves assets to the meta graph.
  
      Args:
        write_fn: A function callback that writes assets into meta graph.
        assets_to_add: The list where the asset paths are setup.
  
      Returns:
        A dict of asset basenames for saving to the original full path to the asset.
  
      Raises:
        ValueError: Indicating an invalid filepath tensor.
      """
      # Map of target file names to original filenames
      asset_filename_map = {}
  
      if assets_to_add is None:
          tf_logging.info("No assets to save.")
          return asset_filename_map
  
      # Iterate over the supplied assets, build the `AssetFile` proto and add them
      # to the meta graph.
      for asset_tensor in assets_to_add:
          asset_source_filepath = _asset_path_from_tensor(asset_tensor)
          if not asset_source_filepath:
              raise ValueError(
                  f"Asset filepath tensor {asset_tensor} in is invalid."
              )
  
          asset_filename = get_asset_filename_to_add(
              asset_source_filepath, asset_filename_map
          )
  
          # Call the passed-in function that builds AssetFileDef proto and adds it
          # to either the collection or asset_file_def field of the meta graph.
          # Note that this should be done even when the file is a duplicate of an
          # already-added file, as the tensor reference should still exist.
          write_fn(asset_filename, asset_tensor)
  
          # In the cases where we are adding a duplicate, this will result in the
          # last of the filepaths being the one used for copying the file to the
          # SavedModel. Since the files in question are the same, it doesn't matter
          # either way.
          asset_filename_map[asset_filename] = asset_source_filepath
  
      tf_logging.info("Assets added to graph.")
      return asset_filename_map
  
imports: import functools
  import os
  from google.protobuf.any_pb2 import Any
  from tensorflow.core.framework import types_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.core.protobuf import saved_model_pb2
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.saved_model import fingerprinting_utils
  from tensorflow.python.saved_model import path_helpers
  from tensorflow.python.saved_model import signature_def_utils
  from tensorflow.python.saved_model.pywrap_saved_model import constants
  from tensorflow.python.saved_model.pywrap_saved_model import metrics
  from tensorflow.python.training import saver
  from tensorflow.python.util import compat
  from tensorflow.python.util.deprecation import deprecated_args
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 for calling a global function with example usage: _maybe_save_assets(write_fn, assets_to_add) and returns: asset_filename_map, asset_filename_map