class_docstr: Handles a SavedModel exported using TF 1.x APIs in TF 2.x.
class_docstr_tok: ["Handles","a","SavedModel","exported","using","TF","1.x","APIs","in","TF","2.x","."]
docstr: Init method for SavedModelLoader.
  
  Args:
    saved_model_dir: A SavedModel directory providing a transform graph.  The
      MetaGraphDef and signature are selected from the SavedModel using keys
      defined in `../constants.py` ('transform' and 'transform_signature',
      respectively).
docstr_tok: ["Init","method","for","SavedModelLoader",".","Args",":","saved_model_dir",":","A","SavedModel","directory","providing","a","transform","graph",".","The","MetaGraphDef","and","signature","are","selected","from","the","SavedModel","using","keys","defined","in","`","..","\/constants.py","`","(","'transform","'","and","'transform_signature","'",",","respectively",")","."]
code: def __init__(self, saved_model_dir: str):
      """Init method for SavedModelLoader.
  
      Args:
        saved_model_dir: A SavedModel directory providing a transform graph.  The
          MetaGraphDef and signature are selected from the SavedModel using keys
          defined in `../constants.py` ('transform' and 'transform_signature',
          respectively).
      """
      imported = tf.saved_model.load(saved_model_dir)
      load_v2_in_compat = (
          constants.TRANSFORM_SIGNATURE in imported.signatures
      )
      if load_v2_in_compat:
          restored_function = imported.signatures[
              constants.TRANSFORM_SIGNATURE
          ]
          (
              wrapped,
              structured_inputs,
              structured_outputs,
          ) = _restore_from_v1_saved_model(
              restored_function, saved_model_dir
          )
      else:
          # transform_fn is now a ConcreteFunction, but was a tf.function. We need
          # to handle both to maintain backward compatiblity. If it's a tf.function,
          # since `input_signature` was specified when exporting the tf function to
          # `SavedModel`, there should be exactly one concrete function present on
          # loading the `SavedModel`.
          if hasattr(imported.transform_fn, "concrete_functions"):
              concrete_functions = (
                  imported.transform_fn.concrete_functions
              )
              assert len(concrete_functions) == 1, concrete_functions
              wrapped = concrete_functions[0]
          else:
              wrapped = imported.transform_fn
          func_graph = wrapped.graph
          structured_inputs = (
              tf2_utils.get_structured_inputs_from_func_graph(
                  func_graph
              )
          )
          structured_outputs = tf.nest.pack_sequence_as(
              func_graph.structured_outputs,
              func_graph.outputs,
              expand_composites=True,
          )
      outputs_to_inputs_map = _get_output_to_inputs_map(
          structured_outputs
      )
      self._initialize(
          load_v2_in_compat,
          imported,
          wrapped,
          structured_inputs,
          structured_outputs,
          outputs_to_inputs_map,
      )
      saved_transform_io._maybe_register_addon_ops()
  
imports: from typing import Any, Dict, Iterable, Mapping, Tuple, Union
  import tensorflow
  from tensorflow_transform import annotators
  from tensorflow_transform import common_types
  from tensorflow_transform import graph_tools
  from tensorflow_transform import tf2_utils
  from tensorflow_transform import tf_utils
  from tensorflow_transform.py_func import pyfunc_helper
  from tensorflow_transform.saved import constants
  from tensorflow_transform.saved import saved_model_loader
  from tensorflow_transform.saved import saved_transform_io
  from tensorflow.python.eager import function
  from tensorflow.python.eager import wrap_function
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.ops import lookup_ops
  from tensorflow.python.util import object_identity
label_desc: Use image node_id 1 to create a new SavedModelLoader object  with example: obj = SavedModelLoader(saved_model_dir)