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: Runs inference on a single batch of tensor data.
  
  This method is called by `TorchPredictor.predict` after converting the
  original data batch to torch tensors.
  
  Override this method to add custom logic for processing the model input or
  output.
  
  Example:
  
      .. testcode::
  
          # List outputs are not supported by default TensorflowPredictor.
          def build_model() -> tf.keras.Model:
              input = tf.keras.layers.Input(shape=1)
              model = tf.keras.models.Model(inputs=input, outputs=[input, input])
              return model
  
          # Use a custom predictor to format model output as a dict.
          class CustomPredictor(TensorflowPredictor):
              def call_model(self, inputs):
                  model_output = super().call_model(inputs)
                  return {
                      str(i): model_output[i] for i in range(len(model_output))
                  }
  
          import numpy as np
          data_batch = np.array([[0.5], [0.6], [0.7]], dtype=np.float32)
  
          predictor = CustomPredictor(model=build_model())
          predictions = predictor.predict(data_batch)
  
  Args:
      inputs: A batch of data to predict on, represented as either a single
          TensorFlow tensor or for multi-input models, a dictionary of tensors.
  
  Returns:
      The model outputs, either as a single tensor or a dictionary of tensors.
docstr_tok: ["Runs","inference","on","a","single","batch","of","tensor","data",".","This","method","is","called","by","`","TorchPredictor.predict","`","after","converting","the","original","data","batch","to","torch","tensors",".","Override","this","method","to","add","custom","logic","for","processing","the","model","input","or","output",".","Example",":","..","testcode",":",":","#","List","outputs","are","not","supported","by","default","TensorflowPredictor",".","def","build_model","(",")","-",">","tf.keras.Model",":","input","=","tf.keras.layers.Input","(","shape=1",")","model","=","tf.keras.models.Model","(","inputs=input",",","outputs=","[","input",",","input","]",")","return","model","#","Use","a","custom","predictor","to","format","model","output","as","a","dict",".","class","CustomPredictor","(","TensorflowPredictor",")",":","def","call_model","(","self",",","inputs",")",":","model_output","=","super","(",")",".call_model","(","inputs",")","return","{","str","(","i",")",":","model_output","[","i","]","for","i","in","range","(","len","(","model_output",")",")","}","import","numpy","as","np","data_batch","=","np.array","(","[","[","0.5","]",",","[","0.6","]",",","[","0.7","]","]",",","dtype=np.float32",")","predictor","=","CustomPredictor","(","model=build_model","(",")",")","predictions","=","predictor.predict","(","data_batch",")","Args",":","inputs",":","A","batch","of","data","to","predict","on",",","represented","as","either","a","single","TensorFlow","tensor","or","for","multi-input","models",",","a","dictionary","of","tensors",".","Returns",":","The","model","outputs",",","either","as","a","single","tensor","or","a","dictionary","of","tensors","."]
code: def call_model(
      self, inputs: Union[tf.Tensor, Dict[str, tf.Tensor]]
  ) -> Union[tf.Tensor, Dict[str, tf.Tensor]]:
      """Runs inference on a single batch of tensor data.
  
      This method is called by `TorchPredictor.predict` after converting the
      original data batch to torch tensors.
  
      Override this method to add custom logic for processing the model input or
      output.
  
      Example:
  
          .. testcode::
  
              # List outputs are not supported by default TensorflowPredictor.
              def build_model() -> tf.keras.Model:
                  input = tf.keras.layers.Input(shape=1)
                  model = tf.keras.models.Model(inputs=input, outputs=[input, input])
                  return model
  
              # Use a custom predictor to format model output as a dict.
              class CustomPredictor(TensorflowPredictor):
                  def call_model(self, inputs):
                      model_output = super().call_model(inputs)
                      return {
                          str(i): model_output[i] for i in range(len(model_output))
                      }
  
              import numpy as np
              data_batch = np.array([[0.5], [0.6], [0.7]], dtype=np.float32)
  
              predictor = CustomPredictor(model=build_model())
              predictions = predictor.predict(data_batch)
  
      Args:
          inputs: A batch of data to predict on, represented as either a single
              TensorFlow tensor or for multi-input models, a dictionary of tensors.
  
      Returns:
          The model outputs, either as a single tensor or a dictionary of tensors.
  
      """
      if self.use_gpu:
          with tf.device("GPU:0"):
              return self._model(inputs)
      else:
          return self._model(inputs)
  
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 4 for calling the TensorflowPredictor obj's underlying member method code with example usage: obj.call_model(inputs) and returns: self, self