class_docstr: A predictor for TensorFlow models.
  
  Args:
      model: A Tensorflow Keras model to use for predictions.
      preprocessor: A preprocessor used to transform data batches prior
          to prediction.
      model_weights: List of weights to use for the model.
      use_gpu: If set, the model will be moved to GPU on instantiation and
          prediction happens on GPU.
class_docstr_tok: ["A","predictor","for","TensorFlow","models",".","Args",":","model",":","A","Tensorflow","Keras","model","to","use","for","predictions",".","preprocessor",":","A","preprocessor","used","to","transform","data","batches","prior","to","prediction",".","model_weights",":","List","of","weights","to","use","for","the","model",".","use_gpu",":","If","set",",","the","model","will","be","moved","to","GPU","on","instantiation","and","prediction","happens","on","GPU","."]
docstr: Run inference on data batch.
  
  If the provided data is a single array or a dataframe/table with a single
  column, it will be converted into a single Tensorflow tensor before being
  inputted to the model.
  
  If the provided data is a multi-column table or a dict of numpy arrays,
  it will be converted into a dict of tensors before being inputted to the
  model. This is useful for multi-modal inputs (for example your model accepts
  both image and text).
  
  Args:
      data: A batch of input data. Either a pandas DataFrame or numpy
          array.
      dtype: The dtypes to use for the tensors. Either a single dtype for all
          tensors or a mapping from column name to dtype.
  
  Examples:
  
  .. testcode::
  
      import numpy as np
      import tensorflow as tf
      from ray.train.tensorflow import TensorflowPredictor
  
      def build_model():
          return tf.keras.Sequential(
              [
                  tf.keras.layers.InputLayer(input_shape=()),
                  tf.keras.layers.Flatten(),
                  tf.keras.layers.Dense(1),
              ]
          )
  
      weights = [np.array([[2.0]]), np.array([0.0])]
      predictor = TensorflowPredictor(model=build_model())
  
      data = np.asarray([1, 2, 3])
      predictions = predictor.predict(data)
  
      import pandas as pd
      import tensorflow as tf
      from ray.train.tensorflow import TensorflowPredictor
  
      def build_model():
          input1 = tf.keras.layers.Input(shape=(1,), name="A")
          input2 = tf.keras.layers.Input(shape=(1,), name="B")
          merged = tf.keras.layers.Concatenate(axis=1)([input1, input2])
          output = tf.keras.layers.Dense(2, input_dim=2)(merged)
          return tf.keras.models.Model(
              inputs=[input1, input2], outputs=output)
  
      predictor = TensorflowPredictor(model=build_model())
  
      # Pandas dataframe.
      data = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"])
  
      predictions = predictor.predict(data)
  
  Returns:
      DataBatchType: Prediction result. The return type will be the same as the
          input type.
docstr_tok: ["Run","inference","on","data","batch",".","If","the","provided","data","is","a","single","array","or","a","dataframe\/table","with","a","single","column",",","it","will","be","converted","into","a","single","Tensorflow","tensor","before","being","inputted","to","the","model",".","If","the","provided","data","is","a","multi-column","table","or","a","dict","of","numpy","arrays",",","it","will","be","converted","into","a","dict","of","tensors","before","being","inputted","to","the","model",".","This","is","useful","for","multi-modal","inputs","(","for","example","your","model","accepts","both","image","and","text",")",".","Args",":","data",":","A","batch","of","input","data",".","Either","a","pandas","DataFrame","or","numpy","array",".","dtype",":","The","dtypes","to","use","for","the","tensors",".","Either","a","single","dtype","for","all","tensors","or","a","mapping","from","column","name","to","dtype",".","Examples",":","..","testcode",":",":","import","numpy","as","np","import","tensorflow","as","tf","from","ray.train.tensorflow","import","TensorflowPredictor","def","build_model","(",")",":","return","tf.keras.Sequential","(","[","tf.keras.layers.InputLayer","(","input_shape=","(",")",")",",","tf.keras.layers.Flatten","(",")",",","tf.keras.layers.Dense","(","1",")",",","]",")","weights","=","[","np.array","(","[","[","2.0","]","]",")",",","np.array","(","[","0.0","]",")","]","predictor","=","TensorflowPredictor","(","model=build_model","(",")",")","data","=","np.asarray","(","[","1",",","2",",","3","]",")","predictions","=","predictor.predict","(","data",")","import","pandas","as","pd","import","tensorflow","as","tf","from","ray.train.tensorflow","import","TensorflowPredictor","def","build_model","(",")",":","input1","=","tf.keras.layers.Input","(","shape=","(","1",",",")",",","name=","''","A","''",")","input2","=","tf.keras.layers.Input","(","shape=","(","1",",",")",",","name=","''","B","''",")","merged","=","tf.keras.layers.Concatenate","(","axis=1",")","(","[","input1",",","input2","]",")","output","=","tf.keras.layers.Dense","(","2",",","input_dim=2",")","(","merged",")","return","tf.keras.models.Model","(","inputs=","[","input1",",","input2","]",",","outputs=output",")","predictor","=","TensorflowPredictor","(","model=build_model","(",")",")","#","Pandas","dataframe",".","data","=","pd.DataFrame","(","[","[","1",",","2","]",",","[","3",",","4","]","]",",","columns=","[","``","A","''",",","``","B","''","]",")","predictions","=","predictor.predict","(","data",")","Returns",":","DataBatchType",":","Prediction","result",".","The","return","type","will","be","the","same","as","the","input","type","."]
code: def predict(
      self,
      data: DataBatchType,
      dtype: Optional[
          Union[tf.dtypes.DType, Dict[str, tf.dtypes.DType]]
      ] = None,
  ) -> DataBatchType:
      """Run inference on data batch.
  
      If the provided data is a single array or a dataframe/table with a single
      column, it will be converted into a single Tensorflow tensor before being
      inputted to the model.
  
      If the provided data is a multi-column table or a dict of numpy arrays,
      it will be converted into a dict of tensors before being inputted to the
      model. This is useful for multi-modal inputs (for example your model accepts
      both image and text).
  
      Args:
          data: A batch of input data. Either a pandas DataFrame or numpy
              array.
          dtype: The dtypes to use for the tensors. Either a single dtype for all
              tensors or a mapping from column name to dtype.
  
      Examples:
  
      .. testcode::
  
          import numpy as np
          import tensorflow as tf
          from ray.train.tensorflow import TensorflowPredictor
  
          def build_model():
              return tf.keras.Sequential(
                  [
                      tf.keras.layers.InputLayer(input_shape=()),
                      tf.keras.layers.Flatten(),
                      tf.keras.layers.Dense(1),
                  ]
              )
  
          weights = [np.array([[2.0]]), np.array([0.0])]
          predictor = TensorflowPredictor(model=build_model())
  
          data = np.asarray([1, 2, 3])
          predictions = predictor.predict(data)
  
          import pandas as pd
          import tensorflow as tf
          from ray.train.tensorflow import TensorflowPredictor
  
          def build_model():
              input1 = tf.keras.layers.Input(shape=(1,), name="A")
              input2 = tf.keras.layers.Input(shape=(1,), name="B")
              merged = tf.keras.layers.Concatenate(axis=1)([input1, input2])
              output = tf.keras.layers.Dense(2, input_dim=2)(merged)
              return tf.keras.models.Model(
                  inputs=[input1, input2], outputs=output)
  
          predictor = TensorflowPredictor(model=build_model())
  
          # Pandas dataframe.
          data = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"])
  
          predictions = predictor.predict(data)
  
      Returns:
          DataBatchType: Prediction result. The return type will be the same as the
              input type.
      """
      return super(TensorflowPredictor, self).predict(
          data=data, dtype=dtype
      )
  
file_path: ray/python/ray/train/tensorflow/tensorflow_predictor.py
imports: import logging
  from typing import TYPE_CHECKING, Callable, Dict, Optional, Type, Union
  import numpy
  import tensorflow
  from ray.air._internal.tensorflow_utils import convert_ndarray_batch_to_tf_tensor_batch
  from ray.train._internal.dl_predictor import DLPredictor
  from ray.train.predictor import DataBatchType
  from ray.train.tensorflow import TensorflowCheckpoint
  from ray.util import log_once
  from ray.util.annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 5 for calling the TensorflowPredictor obj's underlying member method code with example usage: obj.predict(data, dtype) and returns: super