def _infer_metadata_from_saved_model_v1(
    saved_model_dir: str) -> dataset_metadata.DatasetMetadata:
  """Infers a DatasetMetadata for outputs of a TF1 SavedModel."""
  with tf.compat.v1.Graph().as_default() as graph:
    with tf.compat.v1.Session(graph=graph) as session:
      _, outputs = (
          saved_transform_io.partially_apply_saved_transform_internal(
              saved_model_dir, {}))

      session.run(tf.compat.v1.global_variables_initializer())
      session.run(tf.compat.v1.tables_initializer())
      return dataset_metadata.DatasetMetadata(
          schema=schema_inference.infer_feature_schema(outputs, graph, session))
Infers a DatasetMetadata for outputs of a TF1 SavedModel.
tensorflow_transform/beam/impl.py