class_docstr: Interface for torch models.
class_docstr_tok: ["Interface","for","torch","models","."]
docstr: Predict on the given input.
  
  Parameters
  ----------
  x: np.ndarray
      A given input that the wrapped model predicts on.
  grad: boolean
      Indicates if gradient-calculation is disabled or not.
  kwargs: optional
      Keyword arguments.
  
  Returns
  --------
  np.ndarray
      predictions of the same dimension and shape as the input, values in the range [0, 1].
docstr_tok: ["Predict","on","the","given","input",".","Parameters","--","--","--","--","--","x",":","np.ndarray","A","given","input","that","the","wrapped","model","predicts","on",".","grad",":","boolean","Indicates","if","gradient-calculation","is","disabled","or","not",".","kwargs",":","optional","Keyword","arguments",".","Returns","--","--","--","--","np.ndarray","predictions","of","the","same","dimension","and","shape","as","the","input",",","values","in","the","range","[","0",",","1","]","."]
code: def predict(
      self, x: np.ndarray, grad: bool = False, **kwargs
  ) -> np.array:
      """
      Predict on the given input.
  
      Parameters
      ----------
      x: np.ndarray
          A given input that the wrapped model predicts on.
      grad: boolean
          Indicates if gradient-calculation is disabled or not.
      kwargs: optional
          Keyword arguments.
  
      Returns
      --------
      np.ndarray
          predictions of the same dimension and shape as the input, values in the range [0, 1].
      """
  
      # Use kwargs of predict call if specified, but don't overwrite object attribute
      model_predict_kwargs = {**self.model_predict_kwargs, **kwargs}
  
      if self.model.training:
          raise AttributeError(
              "Torch model needs to be in the evaluation mode."
          )
  
      grad_context = torch.no_grad() if not grad else suppress()
  
      with grad_context:
          pred_model = self.get_softmax_arg_model()
          pred = pred_model(
              torch.Tensor(x).to(self.device), **model_predict_kwargs
          )
          if pred.requires_grad:
              return pred.detach().cpu().numpy()
          return pred.cpu().numpy()
  
imports: import copy
  from contextlib import suppress
  from copy import deepcopy
  from typing import Any, Dict, Optional, Tuple, List, Union, Generator
  import warnings
  import logging
  import numpy
  import torch
  from torch import nn
  from functools import lru_cache
  from quantus.helpers import utils
  from quantus.helpers.model.model_interface import ModelInterface
label_desc: Use image node_id 5 for calling the PyTorchModel obj's underlying member method code with example usage: obj.predict(x, grad) and returns: pred, pred