class_docstr: Interface for torch models.
class_docstr_tok: ["Interface","for","torch","models","."]
docstr: Initialisation of PyTorchModel class.
  
  Parameters
  ----------
  model: torch.nn.Module, tf.keras.Model
      A model to be wrapped in the ModelInterface.
  channel_first: boolean, optional
       Indicates of the image dimensions are channel first, or channel last. Inferred from the input shape if None.
  softmax: boolean
      Indicates whether to use softmax probabilities or logits in model prediction.
      This is used for this __call__ only and won't be saved as attribute. If None, self.softmax is used.
  model_predict_kwargs: dict, optional
      Keyword arguments to be passed to the model's predict method.
  device: string
      Indicated the device on which a torch.Tensor is or will be allocated: "cpu" or "gpu".
docstr_tok: ["Initialisation","of","PyTorchModel","class",".","Parameters","--","--","--","--","--","model",":","torch.nn.Module",",","tf.keras.Model","A","model","to","be","wrapped","in","the","ModelInterface",".","channel_first",":","boolean",",","optional","Indicates","of","the","image","dimensions","are","channel","first",",","or","channel","last",".","Inferred","from","the","input","shape","if","None",".","softmax",":","boolean","Indicates","whether","to","use","softmax","probabilities","or","logits","in","model","prediction",".","This","is","used","for","this","__call__","only","and","wo","n't","be","saved","as","attribute",".","If","None",",","self.softmax","is","used",".","model_predict_kwargs",":","dict",",","optional","Keyword","arguments","to","be","passed","to","the","model","'s","predict","method",".","device",":","string","Indicated","the","device","on","which","a","torch.Tensor","is","or","will","be","allocated",":","``","cpu","''","or","``","gpu","''","."]
code: def __init__(
      self,
      model: nn.Module,
      channel_first: bool = True,
      softmax: bool = False,
      model_predict_kwargs: Optional[Dict[str, Any]] = None,
      device: Optional[str] = None,
  ):
      """
      Initialisation of PyTorchModel class.
  
      Parameters
      ----------
      model: torch.nn.Module, tf.keras.Model
          A model to be wrapped in the ModelInterface.
      channel_first: boolean, optional
           Indicates of the image dimensions are channel first, or channel last. Inferred from the input shape if None.
      softmax: boolean
          Indicates whether to use softmax probabilities or logits in model prediction.
          This is used for this __call__ only and won't be saved as attribute. If None, self.softmax is used.
      model_predict_kwargs: dict, optional
          Keyword arguments to be passed to the model's predict method.
      device: string
          Indicated the device on which a torch.Tensor is or will be allocated: "cpu" or "gpu".
      """
      # self.channel_first = channel_first
      super().__init__(
          model=model,
          channel_first=channel_first,
          softmax=softmax,
          model_predict_kwargs=model_predict_kwargs,
      )
      self.device = device
  
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 1 to create a new PyTorchModel object from inherited base classes: ModelInterface with example: obj = PyTorchModel(model, channel_first, softmax, model_predict_kwargs, device)