code: def __init__(
      self,
      model: Any,
      bounds: BoundsInput,
      device: Any = None,
      preprocessing: Preprocessing = None,
  ):
      import torch
  
      if not isinstance(model, torch.nn.Module):
          raise ValueError(
              "expected model to be a torch.nn.Module instance"
          )
  
      if model.training:
          with warnings.catch_warnings():
              warnings.simplefilter("always")
              warnings.warn(
                  "The PyTorch model is in training mode and therefore might"
                  " not be deterministic. Call the eval() method to set it in"
                  " evaluation mode if this is not intended."
              )
  
      device = get_device(device)
      model = model.to(device)
      dummy = ep.torch.zeros(0, device=device)
  
      # we need to make sure the output only requires_grad if the input does
      def _model(x: torch.Tensor) -> torch.Tensor:
          with torch.set_grad_enabled(x.requires_grad):
              result = cast(torch.Tensor, model(x))
          return result
  
      super().__init__(
          _model,
          bounds=bounds,
          dummy=dummy,
          preprocessing=preprocessing,
      )
  
      self.data_format = "channels_first"
      self.device = device
  
file_path: foolbox/foolbox/models/pytorch.py
imports: from typing import Any, cast
  import warnings
  import eagerpy
  from ..types import BoundsInput, Preprocessing
  from .base import ModelWithPreprocessing
label_desc: Use image node_id 1 to create a new PyTorchModel object from inherited base classes: ModelWithPreprocessing with example: obj = PyTorchModel(model, bounds, device, preprocessing)