code: def test_stale_asset_collections_are_cleaned(self):
      vocabulary_file = os.path.join(
          tf.compat.as_bytes(self.get_temp_dir()),
          tf.compat.as_bytes("asset"),
      )
      file_io.write_string_to_file(vocabulary_file, "foo bar baz")
  
      export_path = os.path.join(tempfile.mkdtemp(), "export")
  
      # create a SavedModel including assets
      with tf.compat.v1.Graph().as_default():
          with tf.compat.v1.Session().as_default() as session:
              input_string = tf.compat.v1.placeholder(tf.string)
              # Map string through a table loaded from an asset file
              initializer = tf.lookup.TextFileInitializer(
                  vocabulary_file,
                  key_dtype=tf.string,
                  key_index=tf.lookup.TextFileIndex.WHOLE_LINE,
                  value_dtype=tf.int64,
                  value_index=tf.lookup.TextFileIndex.LINE_NUMBER,
              )
              table = tf.lookup.StaticHashTable(
                  initializer, default_value=12
              )
              table = lookup_ops.IdTableWithHashBuckets(
                  table, num_oov_buckets=12, key_dtype=tf.string
              )
              output = table.lookup(input_string)
              inputs = {"input": input_string}
              outputs = {"output": output}
              saved_transform_io.write_saved_transform_from_session(
                  session, inputs, outputs, export_path
              )
  
      # Load it and save it again repeatedly, verifying that the asset collections
      # remain valid.
      for _ in [1, 2, 3]:
          with tf.compat.v1.Graph().as_default() as g:
              with tf.compat.v1.Session().as_default() as session:
                  input_string = tf.constant("dog")
                  inputs = {"input": input_string}
                  (
                      _,
                      outputs,
                  ) = saved_transform_io.partially_apply_saved_transform_internal(
                      export_path, inputs
                  )
  
                  self.assertEqual(
                      1,
                      len(
                          g.get_collection(
                              tf.compat.v1.GraphKeys.ASSET_FILEPATHS
                          )
                      ),
                  )
                  self.assertEqual(
                      0,
                      len(g.get_collection(tf.saved_model.ASSETS_KEY)),
                  )
  
                  # Check that every ASSET_FILEPATHS refers to a Tensor in the graph.
                  # If not, get_tensor_by_name() raises KeyError.
                  for asset_path in g.get_collection(
                      tf.compat.v1.GraphKeys.ASSET_FILEPATHS
                  ):
                      tensor_name = asset_path.name
                      g.get_tensor_by_name(tensor_name)
  
                  export_path = os.path.join(
                      tempfile.mkdtemp(), "export"
                  )
                  saved_transform_io.write_saved_transform_from_session(
                      session, inputs, outputs, export_path
                  )
  
imports: import os
  import tempfile
  import numpy
  import tensorflow
  from tensorflow_transform.saved import saved_transform_io
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.ops import lookup_ops
label_desc: Use image node_id 12 for calling the SavedTransformIOTest obj's underlying member method code with example usage: obj.test_stale_asset_collections_are_cleaned() without return types