docstr: Outputs predictions for given features.
  
  :param input_fn: A function that constructs the features.
        * A `TFDataset` object, each elements of which is a tuple `(features, None)`.
        * A `tf.data.Dataset` object: Outputs of `Dataset` object must have
          same constraints as below.
        * features: A `tf.Tensor` or a dictionary of string feature name to
          `Tensor`. features are consumed by `model_fn`. They should satisfy
          the expectation of `model_fn` from inputs.
        * A tuple, in which case the first item is extracted as features.
  
  :param checkpoint_path: Path of a specific checkpoint to predict. If `None`, the
      latest checkpoint in `model_dir` is used.  If there are no checkpoints
      in `model_dir`, prediction is run with newly initialized `Variables`
      instead of ones restored from checkpoint.
  
  
  Return:
    Evaluated values of `predictions` tensors.
docstr_tok: ["Outputs","predictions","for","given","features",".",":","param","input_fn",":","A","function","that","constructs","the","features",".","*","A","`","TFDataset","`","object",",","each","elements","of","which","is","a","tuple","`","(","features",",","None",")","`",".","*","A","`","tf.data.Dataset","`","object",":","Outputs","of","`","Dataset","`","object","must","have","same","constraints","as","below",".","*","features",":","A","`","tf.Tensor","`","or","a","dictionary","of","string","feature","name","to","`","Tensor","`",".","features","are","consumed","by","`","model_fn","`",".","They","should","satisfy","the","expectation","of","`","model_fn","`","from","inputs",".","*","A","tuple",",","in","which","case","the","first","item","is","extracted","as","features",".",":","param","checkpoint_path",":","Path","of","a","specific","checkpoint","to","predict",".","If","`","None","`",",","the","latest","checkpoint","in","`","model_dir","`","is","used",".","If","there","are","no","checkpoints","in","`","model_dir","`",",","prediction","is","run","with","newly","initialized","`","Variables","`","instead","of","ones","restored","from","checkpoint",".","Return",":","Evaluated","values","of","`","predictions","`","tensors","."]
code: def predict(self, input_fn, predict_keys=None, checkpoint_path=None):
      """Outputs predictions for given features.
  
      :param input_fn: A function that constructs the features.
            * A `TFDataset` object, each elements of which is a tuple `(features, None)`.
            * A `tf.data.Dataset` object: Outputs of `Dataset` object must have
              same constraints as below.
            * features: A `tf.Tensor` or a dictionary of string feature name to
              `Tensor`. features are consumed by `model_fn`. They should satisfy
              the expectation of `model_fn` from inputs.
            * A tuple, in which case the first item is extracted as features.
  
      :param checkpoint_path: Path of a specific checkpoint to predict. If `None`, the
          latest checkpoint in `model_dir` is used.  If there are no checkpoints
          in `model_dir`, prediction is run with newly initialized `Variables`
          instead of ones restored from checkpoint.
  
  
      Return:
        Evaluated values of `predictions` tensors.
  
      """
      import tensorflow as tf
  
      with tf.Graph().as_default() as g:
          result = self.estimator._call_input_fn(
              input_fn, tf.estimator.ModeKeys.PREDICT
          )
          if isinstance(result, TFDataset):
              spec = self._call_model_fn(
                  result.feature_tensors,
                  None,
                  tf.estimator.ModeKeys.PREDICT,
                  self.config,
              )
              latest_checkpoint = self.estimator.latest_checkpoint()
  
              if latest_checkpoint:
                  checkpoint_path = latest_checkpoint
  
              with tf.Session() as sess:
                  if checkpoint_path:
                      saver = tf.train.Saver()
                      saver.restore(sess, checkpoint_path)
                  else:
                      sess.run(tf.global_variables_initializer())
                  inputs = nest.flatten(result._original_tensors[0])
                  if (
                      isinstance(spec.predictions, dict)
                      and predict_keys is not None
                  ):
                      outputs = [
                          spec.predictions[key] for key in predict_keys
                      ]
                  else:
                      outputs = nest.flatten(spec.predictions)
                  tfnet = TFNet.from_session(
                      sess, inputs=inputs, outputs=outputs
                  )
                  predictions = tfnet.predict(
                      result.get_prediction_data(), mini_batch=True
                  )
  
                  # If predictions is a dict, add back the keys and results is a dict as well.
                  if isinstance(spec.predictions, dict):
                      # Given a list of outputs; return a dict of outputs.
                      def zip_key(outs, keys):
                          if isinstance(outs, list):
                              error_msg = (
                                  "output length is "
                                  + "{} but keys length is {}".format(
                                      len(outs), len(keys)
                                  )
                              )
                              invalidInputError(
                                  len(outs) == len(keys), error_msg
                              )
                          else:
                              outs = [outs]
                          res_dict = {}
                          for out, key in zip(outs, keys):
                              res_dict[key] = out
                          return res_dict
  
                      pred_keys = (
                          sorted(spec.predictions.keys())
                          if not predict_keys
                          else predict_keys
                      )
                      predictions = predictions.map(
                          lambda res: zip_key(res, pred_keys)
                      )
                  return predictions
  
      return list(
          self.estimator.predict(
              input_fn, checkpoint_path=checkpoint_path
          )
      )
  
file_path: BigDL/python/orca/src/bigdl/orca/tfpark/estimator.py
imports: from bigdl.dllib.optim.optimizer import MaxIteration, Loss, TreeNNAccuracy
  from bigdl.orca.tfpark.utils import evaluate_string_metrics
  from bigdl.dllib.keras import metrics
  from bigdl.orca.tfpark.tfnet import TFNet
  from bigdl.orca.tfpark.tf_optimizer import TFOptimizer
  from bigdl.orca.tfpark.tf_dataset import TFDataset
  from bigdl.dllib.utils import nest
  import six
  import os
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 6 for calling the TFEstimator obj's underlying member method code with example usage: obj.predict(input_fn, predict_keys, checkpoint_path) and returns: list, predictions, res_dict