jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def _make_rpc_friendly(model_dir, tag, in_map, out_map, vars_path):
  """Wraps a SavedModel in EE RPC-friendly ops and saves a temporary copy."""
  out_dir = tempfile.mkdtemp()
  builder = tf.saved_model.Builder(out_dir)

  # Get a GraphDef from the saved model
  with tf.compat.v1.Session() as sesh:
    meta_graph = tf.saved_model.load(sesh, [tag], model_dir)

  graph_def = meta_graph.graph_def

  # Purge the default graph immediately after: we want to remap parts of the
  # graph when we load it and we don't know what those parts are yet.
  tf.compat.v1.reset_default_graph()

  input_op_keys = list(in_map.keys())
  input_new_keys = list(in_map.values())

  # Get the shape and type of the input tensors
  in_op_types = _get_input_tensor_spec(graph_def, input_op_keys)

  # Create new input placeholders to receive RPC TensorProto payloads
  in_op_map = {
      k: tf.compat.v1.placeholder(
          tf.string, shape=[None], name='earthengine_in_{}'.format(i))
      for (i, k) in enumerate(input_new_keys)
  }

  # Glue on decoding ops to remap to the imported graph.
  decoded_op_map = {
      k: _decode_op(in_op_map[in_map[k]], in_op_types[k])
      for k in input_op_keys
  }

  # Okay now we're ready to import the graph again but remapped.
  saver = tf.compat.v1.train.import_meta_graph(
      meta_graph_or_file=meta_graph, input_map=decoded_op_map)

  # Boilerplate to build a signature def for our new graph
  sig_in = {
      _strip_index(k):
      saved_model_utils.build_tensor_info(v) for (k, v) in in_op_map.items()
  }

  sig_out = {}
  for index, (k, v) in enumerate(out_map.items()):
    out_tensor = saved_model_utils.build_tensor_info(
        _encode_op(
            tf.compat.v1.get_default_graph().get_tensor_by_name(k),
            name='earthengine_out_{}'.format(index)))

    sig_out[_strip_index(v)] = out_tensor

  sig_def = signature_def_utils.build_signature_def(
      sig_in, sig_out, signature_constants.PREDICT_METHOD_NAME)

  # Open a new session to load the variables and add them to the builder.
  with tf.compat.v1.Session() as sesh:
    if saver:
      saver.restore(sesh, model_dir + vars_path)
    builder.add_meta_graph_and_variables(
        sesh,
        tags=[tf.saved_model.tag_constants.SERVING],
        signature_def_map={
            signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY: sig_def
        },
        saver=saver)

  builder.save()
  return out_dir
//  [python]
def load(self, model_path):
        '''
        load the tf-serving model.
        :param model_path: the mode path.
        :return: the mode path
        '''
        # with tf.Session() as sess:
        sess = tf.Session()
        # load model
        meta_graph_def = tf.saved_model.loader.load(
            sess, [tf.saved_model.tag_constants.SERVING], model_path)
        # get signature
        signature = meta_graph_def.signature_def
        key_my_signature = 'test_signature'
        # get tensor name
        train_ids = []
        for column in self.all_features:
            train_id = signature[key_my_signature].inputs['{}:0'.format(column)].name
            train_ids.append(sess.graph.get_tensor_by_name(train_id))
        for drop_idx in range(len(self.keep_prob)):
            train_ids.append(sess.graph.get_tensor_by_name(
                signature[key_my_signature].inputs['dropout_keep{}:0'.format(drop_idx)].name))
        train_ids.append(sess.graph.get_tensor_by_name(signature[key_my_signature].inputs['train_phase:0'].name))
        preds = []
        for task_idx in range(self.num_tasks):
            preds.append(sess.graph.get_tensor_by_name(
                signature[key_my_signature].outputs['pred{}:0'.format(task_idx)].name))
        self.loaded = True
        self.sess = sess
        self.train_ids = train_ids
        self.preds = preds
        print('Loaded tf-serving model from {}'.format(model_path))
        return model_path
//  [python]
def load(self, model_path):
        '''
        load the tf-serving model.
        :param model_path: the mode path.
        :return: the mode path
        '''
        sess = tf.compat.v1.Session()
        # load model
        meta_graph_def = tf.saved_model.load(
            sess, model_path)
        # get signature
        signature = meta_graph_def.signature_def
        key_my_signature = 'test_signature'
        # get tensor name
        train_ids = []
        for column in self.all_features:
            train_id = signature[key_my_signature].inputs['{}:0'.format(column)].name
            train_ids.append(sess.graph.get_tensor_by_name(train_id))
        for drop_idx in range(len(self.keep_prob)):
            train_ids.append(sess.graph.get_tensor_by_name(
                signature[key_my_signature].inputs['dropout_keep{}:0'.format(drop_idx)].name))
        train_ids.append(sess.graph.get_tensor_by_name(signature[key_my_signature].inputs['train_phase:0'].name))
        preds = []
        for task_idx in range(self.num_tasks):
            preds.append(sess.graph.get_tensor_by_name(
                signature[key_my_signature].outputs['pred{}:0'.format(task_idx)].name))
        self.loaded = True
        self.sess = sess
        self.train_ids = train_ids
        self.preds = preds
        print('Loaded tf-serving model from {}'.format(model_path))
        return model_path
//  [python]
def _from_saved_model_v1(sess, model_path, tag, signatures):
    """
    Load tensorflow graph from saved_model.
    NOTICE: Modified version from tf2onnx project
    """

    wrn_no_tag = "'--tag' not specified for saved_model. Using --tag serve"
    wrn_empty_tag = "'--tag' value is empty string. Using tag =[[]]"

    if tag is None:
        tag = [tf.saved_model.SERVING]
        LOGGER.warning(wrn_no_tag)

    if tag == "":
        tag = [[]]
        LOGGER.warning(wrn_empty_tag)

    if not isinstance(tag, list):
        tag = [tag]

    imported = tf.compat.v1.saved_model.loader.load(sess, tag, model_path)
    for k in imported.signature_def.keys():
        if k.startswith("_"):
            # consider signatures starting with '_' private
            continue
        signatures.append(k)
    try:
        from tensorflow.contrib.saved_model.python.saved_model import (  # pytype: disable=import-error
            signature_def_utils,
        )

        def get_signature_def(meta_graph_def, k):
            return signature_def_utils.get_signature_def_by_key(meta_graph_def, k)

    except ImportError:
        # TF1.12 changed the api
        def get_signature_def(meta_graph_def, k):
            return meta_graph_def.signature_def[k]

    inputs = {}
    outputs = {}
    for k in signatures:
        inputs_tensor_info = get_signature_def(imported, k).inputs
        for name, input_tensor in inputs_tensor_info.items():
            inputs[name] = input_tensor.name
        outputs_tensor_info = get_signature_def(imported, k).outputs
        for name, output_tensor in outputs_tensor_info.items():
            outputs[name] = output_tensor.name
    frozen_graph = freeze_session(sess, input_names=list(inputs.values()), output_names=list(outputs.values()))
    return frozen_graph, inputs, outputs
//  [python]
def _from_saved_model_v1(sess, model_path, tag, signatures):
    """
    Load tensorflow graph from saved_model.
    NOTICE: Modified version from tf2onnx project
    """

    wrn_no_tag = "'--tag' not specified for saved_model. Using --tag serve"
    wrn_empty_tag = "'--tag' value is empty string. Using tag =[[]]"

    if tag is None:
        tag = [tf.saved_model.SERVING]
        LOGGER.warning(wrn_no_tag)

    if tag == "":
        tag = [[]]
        LOGGER.warning(wrn_empty_tag)

    if not isinstance(tag, list):
        tag = [tag]

    imported = tf.saved_model.load(model_path, tags=tag)
    for k in imported.signatures.keys():
        if k.startswith("_"):
            # consider signatures starting with '_' private
            continue
        signatures.append(k)
    try:
        from tensorflow.contrib.saved_model.python.saved_model import (  # pytype: disable=import-error
            signature_def_utils,
        )

        def get_signature_def(meta_graph_def, k):
            return signature_def_utils.get_signature_def_by_key(meta_graph_def, k)

    except ImportError:
        # TF1.12 changed the api
        def get_signature_def(meta_graph_def, k):
            return meta_graph_def.signature_def[k]

    inputs = {}
    outputs = {}
    for k in signatures:
        inputs_tensor_info = get_signature_def(imported, k).inputs
        for name, input_tensor in inputs_tensor_info.items():
            inputs[name] = input_tensor.name
        outputs_tensor_info = get_signature_def(imported, k).outputs
        for name, output_tensor in outputs_tensor_info.items():
            outputs[name] = output_tensor.name
    frozen_graph = freeze_session(sess, input_names=list(inputs.values()), output_names=list(outputs.values()))
    return frozen_graph, inputs, outputs
//  [python]
def benchmark(trt_savedmodel_dir: str, warmup_runs: int = 5, bm_runs: int = 20):
  """Benchmark TRT latency for a given TRT saved model."""
  with tf.Session() as sess:
    # First load the Saved Model into the session
    tf.saved_model.loader.load(sess, [tf.saved_model.tag_constants.SERVING],
                               trt_savedmodel_dir)
    graph = tf.get_default_graph()
    input_shape = graph.get_tensor_by_name('input:0').shape
    x = np.ones(input_shape).astype(np.float32)
    ss = lambda i: '' if i == 0 else '_%d' % i
    outputs = ['box_net/box-predict%s/BiasAdd:0' % ss(i) for i in range(1)]
    outputs += ['class_net/class-predict%s/BiasAdd:0' % ss(i) for i in range(5)]
    # Apply reduce_sum to avoid massive data move between GPU and CPU.
    outputs = [tf.reduce_sum(graph.get_tensor_by_name(i)) for i in outputs]

    # warmup
    for _ in range(warmup_runs):
      sess.run(outputs, feed_dict={'input:0': x})
    # benchmark
    s = time.perf_counter()
    for _ in range(bm_runs):
      sess.run(outputs, feed_dict={'input:0': x})
    e = time.perf_counter()
    print('Benchmark latency=%.4f  FPS=%.2f', (e - s) / bm_runs,
          bm_runs / (e - s))
//  [python]
def benchmark(trt_savedmodel_dir: str, warmup_runs: int = 5, bm_runs: int = 20):
  """Benchmark TRT latency for a given TRT saved model."""
  m = tf.saved_model.load(trt_savedmodel_dir)
  graph = m.signatures['serving_default'].graph
  input_shape = graph.get_tensor_by_name('input:0').shape
  x = np.ones(input_shape).astype(np.float32)
  ss = lambda i: '' if i == 0 else '_%d' % i
  outputs = ['box_net/box-predict%s/BiasAdd:0' % ss(i) for i in range(1)]
  outputs += ['class_net/class-predict%s/BiasAdd:0' % ss(i) for i in range(5)]
  # Apply reduce_sum to avoid massive data move between GPU and CPU.
  outputs = [tf.reduce_sum(graph.get_tensor_by_name(i)) for i in outputs]

  # warmup
  for _ in range(warmup_runs):
    m.signatures['serving_default'](input=x)
  # benchmark
  s = time.perf_counter()
  for _ in range(bm_runs):
    m.signatures['serving_default'](input=x)
  e = time.perf_counter()
  print('Benchmark latency=%.4f  FPS=%.2f', (e - s) / bm_runs,
        bm_runs / (e - s))
//  [python]
def run_pred(self,
               export_path,
               key=tf.compat.v1.saved_model.signature_constants.
               DEFAULT_SERVING_SIGNATURE_DEF_KEY):
    g = tf.Graph()
    with g.as_default(), self.session() as sess:
      imported = tf.compat.v1.saved_model.load(
          sess, {tf.compat.v1.saved_model.tag_constants.SERVING}, export_path)
      pred_name = imported.signature_def[key].outputs["output"].name
      pred = g.get_tensor_by_name(pred_name)
      return sess.run(pred)
//  [python]
def run_pred(self,
               export_path,
               key=tf.saved_model.signature_constants.
               DEFAULT_SERVING_SIGNATURE_DEF_KEY):
    g = tf.Graph()
    with g.as_default(), self.session() as sess:
      imported = tf.saved_model.load(
          sess, export_path)
      pred_name = imported.signature_def[key].outputs["output"].name
      pred = g.get_tensor_by_name(pred_name)
      return sess.run(pred)
//  [python]
def load_and_run_v1(self,
                      model_dir,
                      inputs,
                      signature_key=tf1.saved_model.signature_constants
                      .DEFAULT_SERVING_SIGNATURE_DEF_KEY):
    """Load a SavedModel into a TF 1.x-style graph and run `signature_key`."""
    graph = tf.Graph()
    with graph.as_default(), tf1.Session() as session:
      meta_graph_def = tf1.saved_model.load(
          session, [tf1.saved_model.tag_constants.SERVING], model_dir)
      signature = meta_graph_def.signature_def[signature_key]
      feed_dict = {}
      for arg_name in inputs.keys():
        input_tensor = session.graph.get_tensor_by_name(
            signature.inputs[arg_name].name)
        feed_dict[input_tensor] = inputs[arg_name]
      output_dict = {}
      for output_name, output_tensor_info in signature.outputs.items():
        output_dict[output_name] = session.graph.get_tensor_by_name(
            output_tensor_info.name)
      return session.run(output_dict, feed_dict)["output_0"]
//  [python]
def load_and_run_v1(self,
                      model_dir,
                      inputs,
                      signature_key=tf.saved_model.signature_constants
                      .DEFAULT_SERVING_SIGNATURE_DEF_KEY):
    """Load a SavedModel into a TF 1.x-style graph and run `signature_key`."""
    graph = tf.Graph()
    with graph.as_default(), tf.compat.v1.Session() as session:
      meta_graph_def = tf.saved_model.load(
          session, [tf.saved_model.SERVING], model_dir)
      signature = meta_graph_def.signature_def[signature_key]
      feed_dict = {}
      for arg_name in inputs.keys():
        input_tensor = session.graph.get_tensor_by_name(
            signature.inputs[arg_name].name)
        feed_dict[input_tensor] = inputs[arg_name]
      output_dict = {}
      for output_name, output_tensor_info in signature.outputs.items():
        output_dict[output_name] = session.graph.get_tensor_by_name(
            output_tensor_info.name)
      return session.run(output_dict, feed_dict)["output_0"]
//  [python]
def getSess():
    flags = tf.flags
    FLAGS = flags.FLAGS

    flags.DEFINE_string(
        "export_dir", './export_amelia/bert_small_sharepoint_10epoch_dropout/',
        "The dir where the exported model has been written.")
    
    tokenizer = tokenization.FullTokenizer(vocab_file='./bert_model_serve_sharepoint/vocab.txt', do_lower_case=True)
    sess = tf.InteractiveSession()
    tf.saved_model.loader.load(sess, [tag_constants.SERVING], FLAGS.export_dir)
    return sess, tokenizer
//  [python]
def getSess():
    flags = tf.flags
    FLAGS = flags.FLAGS

    flags.DEFINE_string(
        "export_dir", './export_amelia/bert_small_sharepoint_10epoch_dropout/',
        "The dir where the exported model has been written.")
    
    tokenizer = tokenization.FullTokenizer(vocab_file='./bert_model_serve_sharepoint/vocab.txt', do_lower_case=True)
    sess = tf.compat.v1.InteractiveSession()
    tf.saved_model.load(sess, FLAGS.export_dir)
    return sess, tokenizer
//  [python]
def __init__(self, keras_model):
        # Convert Keras model to SavedModel.
        saved_model_dir = tempfile.mkdtemp("tflite-transfer-keras-model")
        tf.compat.v1.keras.experimental.export_saved_model(keras_model, saved_model_dir)

        # Pre-fetch some information about the model.
        with tfv1.Session(graph=tf.Graph()) as sess:
            metagraph = tfv1.saved_model.load(
                sess, [tf.saved_model.SERVING], saved_model_dir
            )
            self._predict_signature = metagraph.signature_def.get("serving_default")

            input_def = next(self._predict_signature.inputs.values().__iter__())
            self._input_shape = tuple(
                dim.size for dim in input_def.tensor_shape.dim[1:]
            )

            variables = tfv1.global_variables()
            self._variable_names = [variable.name for variable in variables]
            self._initial_params = [variable.eval() for variable in variables]
            trainable_variables = keras_model.trainable_variables
            self._trainable_variable_names = [
                variable.name for variable in trainable_variables
            ]

        with tfv1.Session(graph=tf.Graph()) as sess:
            eval_metagraph = tfv1.saved_model.load(sess, ["eval"], saved_model_dir)
            self._eval_signature = eval_metagraph.signature_def.get("eval")

        if len(self._predict_signature.inputs) != 1:
            raise ValueError("Only single-input head models are supported")
        if len(self._predict_signature.outputs) != 1:
            raise ValueError("Only single-output head models are supported")

        # Freeze the model.
        self._frozen_graph_def = self._freeze_keras_saved_model(saved_model_dir)

        # Clean up the temporary directory.
        shutil.rmtree(saved_model_dir)
//  [python]
def __init__(self, keras_model):
        # Convert Keras model to SavedModel.
        saved_model_dir = tempfile.mkdtemp("tflite-transfer-keras-model")
        tf.compat.v1.keras.experimental.export_saved_model(keras_model, saved_model_dir)

        # Pre-fetch some information about the model.
        with tf.compat.v1.Session(graph=tf.Graph()) as sess:
            metagraph = tf.saved_model.load(sess, [tf.saved_model.SERVING], saved_model_dir)
            self._predict_signature = metagraph.signature_def.get("serving_default")

            input_def = next(self._predict_signature.inputs.values().__iter__())
            self._input_shape = tuple(
                dim.size for dim in input_def.tensor_shape.dim[1:]
            )

            variables = tf.compat.v1.global_variables()
            self._variable_names = [variable.name for variable in variables]
            self._initial_params = [variable.eval() for variable in variables]
            trainable_variables = keras_model.trainable_variables
            self._trainable_variable_names = [
                variable.name for variable in trainable_variables
            ]

        with tf.compat.v1.Session(graph=tf.Graph()) as sess:
            eval_metagraph = tf.saved_model.load(sess, ["eval"], saved_model_dir)
            self._eval_signature = eval_metagraph.signature_def.get("eval")

        if len(self._predict_signature.inputs) != 1:
            raise ValueError("Only single-input head models are supported")
        if len(self._predict_signature.outputs) != 1:
            raise ValueError("Only single-output head models are supported")

        # Freeze the model.
        self._frozen_graph_def = self._freeze_keras_saved_model(saved_model_dir)

        # Clean up the temporary directory.
        shutil.rmtree(saved_model_dir)
//  [python]
def getSess():
	flags = tf.flags

	FLAGS = flags.FLAGS

	flags.DEFINE_string(
		"export_dir", 'export/1547709290',
		"The dir where the exported model has been written.")

	processor, tokenizer, label_list, predict_file = test_seving_model.main('_')
	print(predict_file)
	sess = tf.InteractiveSession()
	tf.saved_model.loader.load(sess, [tag_constants.SERVING], FLAGS.export_dir)

	labels = dict()
	for i,l in enumerate(sorted(label_list)):
		labels[l] = i
	label_real = list(labels.keys())
	return sess,FLAGS,processor, tokenizer, label_real, predict_file
//  [python]
def getSess():
	flags = tf.flags

	FLAGS = flags.FLAGS

	flags.DEFINE_string(
		"export_dir", 'export/1547709290',
		"The dir where the exported model has been written.")

	processor, tokenizer, label_list, predict_file = test_seving_model.main('_')
	print(predict_file)
	sess = tf.compat.v1.InteractiveSession()
	tf.saved_model.load(sess, FLAGS.export_dir)

	labels = dict()
	for i,l in enumerate(sorted(label_list)):
		labels[l] = i
	label_real = list(labels.keys())
	return sess,FLAGS,processor, tokenizer, label_real, predict_file
//  [python]
def getSess():
    flags = tf.flags
    FLAGS = flags.FLAGS

    flags.DEFINE_string(
        "export_dir", '../../export_models/percent80/',
        "The dir where the exported model has been written.")
    
    tokenizer = tokenization.FullTokenizer(vocab_file='../../embeddings/uncased_L-12_H-768_A-12/vocab.txt', do_lower_case=True)
    sess = tf.InteractiveSession()
    tf.saved_model.loader.load(sess, [tag_constants.SERVING], FLAGS.export_dir)
    return sess, tokenizer
//  [python]
def getSess():
    flags = tf.flags
    FLAGS = flags.FLAGS

    flags.DEFINE_string(
        "export_dir", '../../export_models/percent80/',
        "The dir where the exported model has been written.")
    
    tokenizer = tokenization.FullTokenizer(vocab_file='../../embeddings/uncased_L-12_H-768_A-12/vocab.txt', do_lower_case=True)
    sess = tf.compat.v1.InteractiveSession()
    tf.saved_model.load(sess, FLAGS.export_dir)
    return sess, tokenizer
//  [python]
def transform(self, data):
        """Return imputed data by trained GAIN model.
        
        Args:
            - data: 2d numpy array with missing data
            
        Returns:
            - imputed data: 2d numpy array without missing data
        """
        # Only after fitting
        assert self.norm_parameters is not None
        assert os.path.exists(self.save_file_directory) is True

        min_val = self.norm_parameters["min"]
        max_val = self.norm_parameters["max"]

        no, dim = data.shape
        # Set missing
        m = 1 - (1 * (np.isnan(data)))
        x = np.nan_to_num(data)

        ## Imputed data
        z = self.sample_Z(no, dim)
        x = m * x + (1 - m) * z

        # Restore the trained GAIN model
        graph = tf.Graph()
        with graph.as_default():
            with tf.Session() as sess:
                tf.saved_model.loader.load(sess, [tag_constants.SERVING], self.save_file_directory)
                X = graph.get_tensor_by_name("Placeholder_2:0")
                M = graph.get_tensor_by_name("Placeholder:0")
                G_sample = graph.get_tensor_by_name("Sigmoid:0")

                imputed_data = sess.run(G_sample, feed_dict={X: x, M: m})

        # Renormalize
        for i in range(dim):
            imputed_data[:, i] = imputed_data[:, i] * (max_val[i] + 1e-8)
            imputed_data[:, i] = imputed_data[:, i] + min_val[i]

        # Rounding
        imputed_data = rounding(x, imputed_data)

        return imputed_data
//  [python]
def transform(self, data):
        """Return imputed data by trained GAIN model.
        
        Args:
            - data: 2d numpy array with missing data
            
        Returns:
            - imputed data: 2d numpy array without missing data
        """
        # Only after fitting
        assert self.norm_parameters is not None
        assert os.path.exists(self.save_file_directory) is True

        min_val = self.norm_parameters["min"]
        max_val = self.norm_parameters["max"]

        no, dim = data.shape
        # Set missing
        m = 1 - (1 * (np.isnan(data)))
        x = np.nan_to_num(data)

        ## Imputed data
        z = self.sample_Z(no, dim)
        x = m * x + (1 - m) * z

        # Restore the trained GAIN model
        graph = tf.Graph()
        with graph.as_default():
            with tf.compat.v1.Session() as sess:
                tf.saved_model.load(sess, self.save_file_directory)
                X = graph.get_tensor_by_name("Placeholder_2:0")
                M = graph.get_tensor_by_name("Placeholder:0")
                G_sample = graph.get_tensor_by_name("Sigmoid:0")

                imputed_data = sess.run(G_sample, feed_dict={X: x, M: m})

        # Renormalize
        for i in range(dim):
            imputed_data[:, i] = imputed_data[:, i] * (max_val[i] + 1e-8)
            imputed_data[:, i] = imputed_data[:, i] + min_val[i]

        # Rounding
        imputed_data = rounding(x, imputed_data)

        return imputed_data
//  [python]
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
np.random.seed(10)
# 需要建立一个会话对象，将模型恢复到其中
with tf.Session() as sess:
    """
    第一种加载模型的方式
    """
    # 解析得到 SignatureDef protobuf
    # path = './advanceSaverAPI_model_complex'
    # MetaGraphDef = sm.loader.load(sess, tags=[sm.tag_constants.SERVING], export_dir=path)
    # SignatureDef_d = MetaGraphDef.signature_def
    # SignatureDef = SignatureDef_d['predict']
    #
    # # # 解析得到 3 个变量对应的 TensorInfo protobuf
    # X = SignatureDef.inputs['Input'].name
    # y = SignatureDef.outputs['Output'].name

    """
    第二种方法和第一种方法其实是一样的，就是细节上有点不一样
    """
    path = './advanceSaverAPI_model_complex'
    MetaGraphDef = sm.loader.load(sess, tags=[sm.tag_constants.SERVING], export_dir=path)
    SignatureDef_d = MetaGraphDef.signature_def
    SignatureDef = SignatureDef_d['predict']

    # # 解析得到 3 个变量对应的 TensorInfo protobuf
    X_TensorInfo = SignatureDef.inputs['Input']
    y_TensorInfo = SignatureDef.outputs['Output']
    #
    # # 解析得到具体 Tensor
    # get_tensor_from_tensor_info() 函数中可以不传入 graph 参数，TensorFlow 自动使用默认图
    X = sm.utils.get_tensor_from_tensor_info(X_TensorInfo, sess.graph)
    y = sm.utils.get_tensor_from_tensor_info(y_TensorInfo, sess.graph)
    """
    第三种加载模型的方式,最简单
    """
    # path = './advanceSaverAPI_model_complex'
    # sm.loader.load(sess, tags=[sm.tag_constants.SERVING], export_dir=path)
    # graph = tf.get_default_graph()
    # X = sess.graph.get_tensor_by_name("Input:0")
    # y = sess.graph.get_tensor_by_name("Output:0")

    # 输出结果
    x_ = np.random.random((32, 784))
    predict = sess.run(y, feed_dict={X: x_})
    prediction = tf.argmax(predict, 1)
    print(sess.run(prediction))
//  [python]
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
np.random.seed(10)
# 需要建立一个会话对象，将模型恢复到其中
with tf.compat.v1.Session() as sess:
    """
    第一种加载模型的方式
    """
    # 解析得到 SignatureDef protobuf
    # path = './advanceSaverAPI_model_complex'
    # MetaGraphDef = sm.loader.load(sess, tags=[sm.tag_constants.SERVING], export_dir=path)
    # SignatureDef_d = MetaGraphDef.signature_def
    # SignatureDef = SignatureDef_d['predict']
    #
    # # # 解析得到 3 个变量对应的 TensorInfo protobuf
    # X = SignatureDef.inputs['Input'].name
    # y = SignatureDef.outputs['Output'].name

    """
    第二种方法和第一种方法其实是一样的，就是细节上有点不一样
    """
    path = './advanceSaverAPI_model_complex'
    MetaGraphDef = tf.compat.v1.saved_model.load(sess, tags=[tf.saved_model.SERVING], export_dir=path)
    SignatureDef_d = MetaGraphDef.signature_def
    SignatureDef = SignatureDef_d['predict']

    # # 解析得到 3 个变量对应的 TensorInfo protobuf
    X_TensorInfo = SignatureDef.inputs['Input']
    y_TensorInfo = SignatureDef.outputs['Output']
    #
    # # 解析得到具体 Tensor
    # get_tensor_from_tensor_info() 函数中可以不传入 graph 参数，TensorFlow 自动使用默认图
    X = sm.utils.get_tensor_from_tensor_info(X_TensorInfo, sess.graph)
    y = sm.utils.get_tensor_from_tensor_info(y_TensorInfo, sess.graph)
    """
    第三种加载模型的方式,最简单
    """
    # path = './advanceSaverAPI_model_complex'
    # sm.loader.load(sess, tags=[sm.tag_constants.SERVING], export_dir=path)
    # graph = tf.get_default_graph()
    # X = sess.graph.get_tensor_by_name("Input:0")
    # y = sess.graph.get_tensor_by_name("Output:0")

    # 输出结果
    x_ = np.random.random((32, 784))
    predict = sess.run(y, feed_dict={X: x_})
    prediction = tf.argmax(predict, 1)
    print(sess.run(prediction))
//  [python]
def transform (self, data):
    """Return imputed data by trained GAIN model.
    
    Args:
      - data: 2d numpy array with missing data
      
    Returns:
      - imputed data: 2d numpy array without missing data
    """
    # Only after fitting
    assert self.norm_parameters is not None
    assert os.path.exists(self.save_file_directory) is True
      
    min_val = self.norm_parameters['min']
    max_val = self.norm_parameters['max']
    
    no, dim = data.shape
    # Set missing
    m = 1-(1*(np.isnan(data)))
    x = np.nan_to_num(data)  
    
    ## Imputed data      
    z = self.sample_Z(no, dim)           
    x = m * x + (1-m) * z
    
    # Restore the trained GAIN model    
    graph = tf.Graph()
    with graph.as_default():
      with tf.Session() as sess:
        tf.saved_model.loader.load(sess, [tag_constants.SERVING], self.save_file_directory)
        X = graph.get_tensor_by_name('Placeholder_2:0')
        M = graph.get_tensor_by_name('Placeholder:0')
        G_sample = graph.get_tensor_by_name('Sigmoid:0')
    
        imputed_data = sess.run(G_sample, feed_dict={X: x, M: m})
    
    # Renormalize  
    for i in range(dim):
      imputed_data[:,i] = imputed_data[:,i] * (max_val[i] + 1e-8)    
      imputed_data[:,i] = imputed_data[:,i] + min_val[i]
            
    # Rounding
    imputed_data = rounding(x, imputed_data)
      
    return imputed_data
//  [python]
def transform (self, data):
    """Return imputed data by trained GAIN model.
    
    Args:
      - data: 2d numpy array with missing data
      
    Returns:
      - imputed data: 2d numpy array without missing data
    """
    # Only after fitting
    assert self.norm_parameters is not None
    assert os.path.exists(self.save_file_directory) is True
      
    min_val = self.norm_parameters['min']
    max_val = self.norm_parameters['max']
    
    no, dim = data.shape
    # Set missing
    m = 1-(1*(np.isnan(data)))
    x = np.nan_to_num(data)  
    
    ## Imputed data      
    z = self.sample_Z(no, dim)           
    x = m * x + (1-m) * z
    
    # Restore the trained GAIN model    
    graph = tf.Graph()
    with graph.as_default():
      with tf.Session() as sess:
        tf.saved_model.load(sess, self.save_file_directory)
        X = graph.get_tensor_by_name('Placeholder_2:0')
        M = graph.get_tensor_by_name('Placeholder:0')
        G_sample = graph.get_tensor_by_name('Sigmoid:0')
    
        imputed_data = sess.run(G_sample, feed_dict={X: x, M: m})
    
    # Renormalize  
    for i in range(dim):
      imputed_data[:,i] = imputed_data[:,i] * (max_val[i] + 1e-8)    
      imputed_data[:,i] = imputed_data[:,i] + min_val[i]
            
    # Rounding
    imputed_data = rounding(x, imputed_data)
      
    return imputed_data
//  [python]
def run_bert(optimize_config: str = None):
    if optimize_config is 'disc':
        disc.enable()

    session_config = tf.ConfigProto()
    session_config.allow_soft_placement = True
    session_config.gpu_options.allow_growth = True
    session_config.graph_options.rewrite_options.auto_mixed_precision = 1
    if optimize_config is "xla":
        session_config.graph_options.optimizer_options.global_jit_level = tf.OptimizerOptions.ON_1

    model_dir = "saved_model"
    sess = tf.Session(graph=tf.Graph(), config=session_config)
    tf.saved_model.loader.load(sess, [tag_constants.SERVING], model_dir)

    fetch = [
        "StatefulPartitionedCall:0", "StatefulPartitionedCall:1",
        "StatefulPartitionedCall:2", "StatefulPartitionedCall:3",
        "StatefulPartitionedCall:4"
    ]
    feed_dict = {
        'serving_default_input_1:0': np.ones((30, 10), dtype=int),
        'serving_default_input_2:0': np.zeros((1), dtype=int),
        'serving_default_input_3:0': np.ones((1), dtype=float),
        'serving_default_input_4:0': np.ones((1), dtype=float),
        'serving_default_input_5:0': np.ones((1), dtype=float),
    }


    # warmup.
    for i in range(20):
        outs = sess.run(fetch, feed_dict=feed_dict)

    # evaluate.
    iters = 100
    tic = time.time()
    for i in range(iters):
        outs = sess.run(fetch, feed_dict=feed_dict)
    avg_time = (time.time() - tic) / iters
    print("average time in {} iterations: {} seconds".format(iters, avg_time))
//  [python]
def run_bert(optimize_config: str = None):
    if optimize_config is 'disc':
        disc.enable()

    session_config = tf.compat.v1.ConfigProto()
    session_config.allow_soft_placement = True
    session_config.gpu_options.allow_growth = True
    session_config.graph_options.rewrite_options.auto_mixed_precision = 1
    if optimize_config is "xla":
        session_config.graph_options.optimizer_options.global_jit_level = tf.compat.v1.OptimizerOptions.ON_1

    model_dir = "saved_model"
    sess = tf.compat.v1.Session(graph=tf.Graph(), config=session_config)
    tf.saved_model.load(sess, model_dir)

    fetch = [
        "StatefulPartitionedCall:0", "StatefulPartitionedCall:1",
        "StatefulPartitionedCall:2", "StatefulPartitionedCall:3",
        "StatefulPartitionedCall:4"
    ]
    feed_dict = {
        'serving_default_input_1:0': np.ones((30, 10), dtype=int),
        'serving_default_input_2:0': np.zeros((1), dtype=int),
        'serving_default_input_3:0': np.ones((1), dtype=float),
        'serving_default_input_4:0': np.ones((1), dtype=float),
        'serving_default_input_5:0': np.ones((1), dtype=float),
    }


    # warmup.
    for i in range(20):
        outs = sess.run(fetch, feed_dict=feed_dict)

    # evaluate.
    iters = 100
    tic = time.time()
    for i in range(iters):
        outs = sess.run(fetch, feed_dict=feed_dict)
    avg_time = (time.time() - tic) / iters
    print("average time in {} iterations: {} seconds".format(iters, avg_time))
//  [python]
def __init__(self, model_dirpath):
        model = tf.compat.v1.saved_model.load(str(model_dirpath))
        self.serve = model.signatures['serving_default']
        self.input_shape = self.serve.inputs[0].shape[1:3]
//  [python]
def __init__(self, model_dirpath):
        model = tensorflow.saved_model.load(str(model_dirpath))
        self.serve = model.signatures['serving_default']
        self.input_shape = self.serve.inputs[0].shape[1:3]
//  [python]
def deserialize(cls, data: LoadedFile):
        logger.info('Run deserialization tensorflow SavedModel data.')
        with TimeProfiler('Time to deserialization tensorflow SavedModel data:'):
            try:
                _data = data.raw_data
                if data.path:
                    _data = data.path
                elif not isinstance(data.raw_data, str):
                    f = tempfile.NamedTemporaryFile(delete=True)
                    if isinstance(data.raw_data, bytes):
                        f.write(data.raw_data)
                    else:
                        f.write(data.raw_data.read())
                    f.seek(0)
                    data.path = f.name
                    _data = f.name
                return t.saved_model.load(str(_data))
            except Exception as e:
                raise ModelBinarizationError(f'Error with deserialize model: {e}')
//  [python]
def deserialize(cls, data: LoadedFile):
        logger.info('Run deserialization tensorflow SavedModel data.')
        with TimeProfiler('Time to deserialization tensorflow SavedModel data:'):
            try:
                _data = data.raw_data
                if data.path:
                    _data = data.path
                elif not isinstance(data.raw_data, str):
                    f = tempfile.NamedTemporaryFile(delete=True)
                    if isinstance(data.raw_data, bytes):
                        f.write(data.raw_data)
                    else:
                        f.write(data.raw_data.read())
                    f.seek(0)
                    data.path = f.name
                    _data = f.name
                return tensorflow.saved_model.load(str(_data))
            except Exception as e:
                raise ModelBinarizationError(f'Error with deserialize model: {e}')
//  [python]
def main(_):
  tf.reset_default_graph()

  with tf.Session() as sess:
    files = tf.io.gfile.glob(_INPUT_DATA_PATH_FLAG.value)
    tf_files = tf.convert_to_tensor(files)
    tf_record_data = tf.data.TFRecordDataset(tf_files, compression_type="GZIP")

    # Parses and decodes the TFExamples present in the dataset.
    tf_record_data = tf_record_data.map(parse_example, num_parallel_calls=10)
    tf_record_data = tf_record_data.map(
        decode_images_in_example, num_parallel_calls=10)

    data_iter = tf.data.make_initializable_iterator(tf_record_data)
    # Initialize the dataset.
    print("Initializing the dataset.")
    sess.run(data_iter.initializer)
    data_iter = data_iter.get_next()

    # Skip samples if needed.
    for _ in range(_NUM_SKIP_SAMPLES_FLAG.value):
      sample = sess.run(data_iter)

    # Load the saved model.
    print("Loading the saved model.")
    tf.saved_model.load(sess, {"serve"}, _EXPORTED_MODEL_DIR_FLAG.value)

    # Run inference on samples.
    for idx in range(_NUM_INFERENCE_SAMPLES_FLAG.value):
      sample = sess.run(data_iter)
      # Inputs are cropped/padded to a 256x256 size within the model
      # automatically.
      # We batch the inputs since the model expects a batch of size 1 for
      # inference.
      image_batch = np.expand_dims(sample["image"], axis=0)
      low_res_image_batch = np.expand_dims(sample["low_res_image"], axis=0)
      auxiliary_inputs_batch = np.expand_dims(
          sample["auxiliary_inputs"], axis=0)
      # Run the model on the inputs and obtain the soil moisture prediction.
      raw_outputs = sess.run(
          _OUTPUT_KEY,
          feed_dict={
              _INPUT_IMAGE_KEY: image_batch,
              _LOW_RES_INPUT_IMAGE_KEY: low_res_image_batch,
              _AUXILIARY_INPUT_KEY: auxiliary_inputs_batch
          })
      print(f"Prediction {idx}:", raw_outputs.squeeze())
//  [python]
def initialize_graph(args):
    tf_config = create_tf_config(args.precision)
    graph = tf.compat.v1.Graph()
    with graph.as_default():
        with tf.compat.v1.Session(config=tf_config) as sess:
            meta_graph=tf.compat.v1.saved_model.loader.load(sess, [tf.compat.v1.saved_model.tag_constants.SERVING], args.model_path)
            assert savemodel_valid(meta_graph),"savemodel is invalid"
            model_graph_signature = list(meta_graph.signature_def.items())[0][1]
            input_tensor_names = []
            dummy_inputs=[]
            for input_item in model_graph_signature.inputs.items():
                input_tensor_name = input_item[1].name
                input_tensor_names.append(input_tensor_name)
                if input_item[1].dtype==1:
                    dtype='float32'
                else:
                    dtype='uint8'
                dshape=[int(item.size) for item in input_item[1].tensor_shape.dim]
                if -1 in dshape[1:]:
                    dshape=get_dynamic_inputshape(args.model_path, dshape)
                dummy_inputs.append(generate_data(args.batch_size, dshape, dtype))
            output_tensor_names = []
            for output_item in model_graph_signature.outputs.items():
                output_tensor_name = output_item[1].name
                output_tensor_names.append(output_tensor_name)
            freeze_graph_def = graph_util.convert_variables_to_constants(  
                sess=sess,
                input_graph_def=sess.graph_def,
                output_node_names=[output_name.split(":")[0] for output_name in output_tensor_names])
            if args.disable_optimize:
                freeze_graph_def = optimize_for_inference_lib.optimize_for_inference(
                                        freeze_graph_def, #inputGraph,
                                        [input_name.split(":")[0] for input_name in input_tensor_names], # an array of the input node(s)
                                        [output_name.split(":")[0] for output_name in output_tensor_names], # an array of output nodes
                                        tf.float32.as_datatype_enum)
            input_variables = {in_name : tf.Variable(dummy_inputs[i])
                            for i,in_name in enumerate(input_tensor_names)}
            tf.import_graph_def(freeze_graph_def,name='g',input_map=input_variables)
    return graph,output_tensor_names
//  [python]
def initialize_graph(args):
    tf_config = create_tf_config(args.precision)
    graph = tf.compat.v1.Graph()
    with graph.as_default():
        with tf.compat.v1.Session(config=tf_config) as sess:
            meta_graph = tf.saved_model.load(args.model_path)
            assert savemodel_valid(meta_graph),"savemodel is invalid"
            model_graph_signature = list(meta_graph.signature_def.items())[0][1]
            input_tensor_names = []
            dummy_inputs=[]
            for input_item in model_graph_signature.inputs.items():
                input_tensor_name = input_item[1].name
                input_tensor_names.append(input_tensor_name)
                if input_item[1].dtype==1:
                    dtype='float32'
                else:
                    dtype='uint8'
                dshape=[int(item.size) for item in input_item[1].tensor_shape.dim]
                if -1 in dshape[1:]:
                    dshape=get_dynamic_inputshape(args.model_path, dshape)
                dummy_inputs.append(generate_data(args.batch_size, dshape, dtype))
            output_tensor_names = []
            for output_item in model_graph_signature.outputs.items():
                output_tensor_name = output_item[1].name
                output_tensor_names.append(output_tensor_name)
            freeze_graph_def = graph_util.convert_variables_to_constants(  
                sess=sess,
                input_graph_def=sess.graph_def,
                output_node_names=[output_name.split(":")[0] for output_name in output_tensor_names])
            if args.disable_optimize:
                freeze_graph_def = optimize_for_inference_lib.optimize_for_inference(
                                        freeze_graph_def, #inputGraph,
                                        [input_name.split(":")[0] for input_name in input_tensor_names], # an array of the input node(s)
                                        [output_name.split(":")[0] for output_name in output_tensor_names], # an array of output nodes
                                        tf.float32.as_datatype_enum)
            input_variables = {in_name : tf.Variable(dummy_inputs[i])
                            for i,in_name in enumerate(input_tensor_names)}
            tf.import_graph_def(freeze_graph_def,name='g',input_map=input_variables)
    return graph,output_tensor_names
//  [python]
def test_cased_length10(self):
    preprocess = tf.compat.v1.saved_model.load(
        self._do_export(["d", "##ef", "abc", "ABC"],
                        do_lower_case=False,
                        default_seq_length=10,
                        tokenize_with_offsets=False,
                        use_sp_model=False,
                        experimental_disable_assert=False))
    inputs = tf.constant(["abc def", "ABC DEF"])
    token_ids = preprocess.tokenize(inputs)
    self.assertAllEqual(token_ids,
                        tf.ragged.constant([[[6], [4, 5]], [[7], [1]]]))

    self.assertFalse(hasattr(preprocess, "tokenize_with_offsets"))

    bert_inputs = preprocess(inputs)
    self.assertAllEqual(
        bert_inputs["input_word_ids"],
        tf.constant([[2, 6, 4, 5, 3, 0, 0, 0, 0, 0],
                     [2, 7, 1, 3, 0, 0, 0, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_mask"],
        tf.constant([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
                     [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_type_ids"],
        tf.constant([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]))

    inputs_2 = tf.constant(["d ABC", "ABC abc"])
    token_ids_2 = preprocess.tokenize(inputs_2)
    bert_inputs = preprocess.bert_pack_inputs([token_ids, token_ids_2])
    # Test default seq_length=10.
    self.assertAllEqual(
        bert_inputs["input_word_ids"],
        tf.constant([[2, 6, 4, 5, 3, 4, 7, 3, 0, 0],
                     [2, 7, 1, 3, 7, 6, 3, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_mask"],
        tf.constant([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
                     [1, 1, 1, 1, 1, 1, 1, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_type_ids"],
        tf.constant([[0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
                     [0, 0, 0, 0, 1, 1, 1, 0, 0, 0]]))
//  [python]
def test_cased_length10(self):
    preprocess = tf.saved_model.load(
        self._do_export(["d", "##ef", "abc", "ABC"],
                        do_lower_case=False,
                        default_seq_length=10,
                        tokenize_with_offsets=False,
                        use_sp_model=False,
                        experimental_disable_assert=False))
    inputs = tf.constant(["abc def", "ABC DEF"])
    token_ids = preprocess.tokenize(inputs)
    self.assertAllEqual(token_ids,
                        tf.ragged.constant([[[6], [4, 5]], [[7], [1]]]))

    self.assertFalse(hasattr(preprocess, "tokenize_with_offsets"))

    bert_inputs = preprocess(inputs)
    self.assertAllEqual(
        bert_inputs["input_word_ids"],
        tf.constant([[2, 6, 4, 5, 3, 0, 0, 0, 0, 0],
                     [2, 7, 1, 3, 0, 0, 0, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_mask"],
        tf.constant([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
                     [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_type_ids"],
        tf.constant([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]))

    inputs_2 = tf.constant(["d ABC", "ABC abc"])
    token_ids_2 = preprocess.tokenize(inputs_2)
    bert_inputs = preprocess.bert_pack_inputs([token_ids, token_ids_2])
    # Test default seq_length=10.
    self.assertAllEqual(
        bert_inputs["input_word_ids"],
        tf.constant([[2, 6, 4, 5, 3, 4, 7, 3, 0, 0],
                     [2, 7, 1, 3, 7, 6, 3, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_mask"],
        tf.constant([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
                     [1, 1, 1, 1, 1, 1, 1, 0, 0, 0]]))
    self.assertAllEqual(
        bert_inputs["input_type_ids"],
        tf.constant([[0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
                     [0, 0, 0, 0, 1, 1, 1, 0, 0, 0]]))
//  [python]
def load(self, saved_model_dir_or_frozen_graph: Text):
    """Load the model using saved model or a frozen graph."""
    # Load saved model if it is a folder.
    if tf.saved_model.contains_saved_model(saved_model_dir_or_frozen_graph):
      with tf.compat.v1.Session(graph=tf.Graph()) as sess:
        tf.saved_model.loader.load(sess, [tf.saved_model.SERVING], saved_model_dir_or_frozen_graph)
        self.model = sess.graph
      return

    # Load a frozen graph.
    def wrap_frozen_graph(graph_def, inputs, outputs):
      # https://www.tensorflow.org/guide/migrate
      imports_graph_def_fn = lambda: tf.import_graph_def(graph_def, name='')
      wrapped_import = tf.compat.v1.wrap_function(imports_graph_def_fn, [])
      import_graph = wrapped_import.graph
      return wrapped_import.prune(
          tf.nest.map_structure(import_graph.as_graph_element, inputs),
          tf.nest.map_structure(import_graph.as_graph_element, outputs))

    graph_def = tf.Graph().as_graph_def()
    with tf.io.gfile.GFile(saved_model_dir_or_frozen_graph, 'rb') as f:
      graph_def.ParseFromString(f.read())

    self.model = wrap_frozen_graph(
        graph_def,
        inputs='images:0',
        outputs=['Identity:0', 'Identity_1:0', 'Identity_2:0', 'Identity_3:0'])
//  [python]
def load(self, saved_model_dir_or_frozen_graph: Text):
    """Load the model using saved model or a frozen graph."""
    # Load saved model if it is a folder.
    if tf.saved_model.contains_saved_model(saved_model_dir_or_frozen_graph):
      self.model = tf.saved_model.load(saved_model_dir_or_frozen_graph)
      return

    # Load a frozen graph.
    def wrap_frozen_graph(graph_def, inputs, outputs):
      # https://www.tensorflow.org/guide/migrate
      imports_graph_def_fn = lambda: tf.import_graph_def(graph_def, name='')
      wrapped_import = tf.compat.v1.wrap_function(imports_graph_def_fn, [])
      import_graph = wrapped_import.graph
      return wrapped_import.prune(
          tf.nest.map_structure(import_graph.as_graph_element, inputs),
          tf.nest.map_structure(import_graph.as_graph_element, outputs))

    graph_def = tf.Graph().as_graph_def()
    with tf.io.gfile.GFile(saved_model_dir_or_frozen_graph, 'rb') as f:
      graph_def.ParseFromString(f.read())

    self.model = wrap_frozen_graph(
        graph_def,
        inputs='images:0',
        outputs=['Identity:0', 'Identity_1:0', 'Identity_2:0', 'Identity_3:0'])