class_docstr: This class implements a regressor with the PyTorch framework.
class_docstr_tok: ["This","class","implements","a","regressor","with","the","PyTorch","framework","."]
docstr: Perform prediction for a batch of inputs.
  
  :param x: Input samples.
  :param batch_size: Size of batches.
  :param training_mode: `True` for model set to training mode and `'False` for model set to evaluation mode.
  :return: Array of predictions of shape `(nb_inputs, nb_classes)`.
docstr_tok: ["Perform","prediction","for","a","batch","of","inputs",".",":","param","x",":","Input","samples",".",":","param","batch_size",":","Size","of","batches",".",":","param","training_mode",":","`","True","`","for","model","set","to","training","mode","and","`","'False","`","for","model","set","to","evaluation","mode",".",":","return",":","Array","of","predictions","of","shape","`","(","nb_inputs",",","nb_classes",")","`","."]
code: def predict(  # pylint: disable=W0221
      self,
      x: np.ndarray,
      batch_size: int = 128,
      training_mode: bool = False,
      **kwargs,
  ) -> np.ndarray:
      """
      Perform prediction for a batch of inputs.
  
      :param x: Input samples.
      :param batch_size: Size of batches.
      :param training_mode: `True` for model set to training mode and `'False` for model set to evaluation mode.
      :return: Array of predictions of shape `(nb_inputs, nb_classes)`.
      """
      import torch
      from torch.utils.data import TensorDataset, DataLoader
  
      # Set model mode
      self._model.train(mode=training_mode)
  
      # Apply preprocessing
      x_preprocessed, _ = self._apply_preprocessing(
          x, y=None, fit=False
      )
  
      # Create dataloader
      x_tensor = torch.from_numpy(x_preprocessed)
      dataset = TensorDataset(x_tensor)
      dataloader = DataLoader(
          dataset=dataset, batch_size=batch_size, shuffle=False
      )
  
      results_list = []
      for (x_batch,) in dataloader:
          # Move inputs to device
          x_batch = x_batch.to(self._device)
  
          # Run prediction
          with torch.no_grad():
              model_outputs = self._model(x_batch)
          output = model_outputs[-1]
          output = output.detach().cpu().numpy().astype(np.float32)
          if len(output.shape) == 1:
              output = np.expand_dims(output, axis=1).astype(np.float32)
  
          results_list.append(output)
  
      results = np.vstack(results_list)
  
      # Apply postprocessing
      predictions = self._apply_postprocessing(preds=results, fit=False)
  
      return predictions
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import copy
  import logging
  import os
  import time
  from typing import Any, Dict, List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  import six
  from art import config
  from art.estimators.regression.regressor import RegressorMixin
  from art.estimators.pytorch import PyTorchEstimator
label_desc: Use image node_id 10 for calling the PyTorchRegressor obj's underlying member method code with example usage: obj.predict(x, batch_size, training_mode) and returns: predictions