class_docstr: This module implements the task- and model-specific estimator for PyTorch GOTURN (object tracking).
class_docstr_tok: ["This","module","implements","the","task-","and","model-specific","estimator","for","PyTorch","GOTURN","(","object","tracking",")","."]
docstr: Initialization.
  
  :param model: GOTURN model.
  :param input_shape: Shape of one input sample as expected by the model, e.g. input_shape=(3, 227, 227).
  :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
         maximum values allowed for features. If floats are provided, these will be used as the range of all
         features. If arrays are provided, each value will be considered the bound for a feature, thus
         the shape of clip values needs to match the total number of features.
  :param channels_first: Set channels first or last.
  :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
  :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
  :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
         used for data preprocessing. The first value will be subtracted from the input. The input will then
         be divided by the second one.
  :param device_type: Type of device to be used for model and tensors, if `cpu` run on CPU, if `gpu` run on GPU
                      if available otherwise run on CPU.
docstr_tok: ["Initialization",".",":","param","model",":","GOTURN","model",".",":","param","input_shape",":","Shape","of","one","input","sample","as","expected","by","the","model",",","e.g",".","input_shape=","(","3",",","227",",","227",")",".",":","param","clip_values",":","Tuple","of","the","form","`","(","min",",","max",")","`","of","floats","or","`","np.ndarray","`","representing","the","minimum","and","maximum","values","allowed","for","features",".","If","floats","are","provided",",","these","will","be","used","as","the","range","of","all","features",".","If","arrays","are","provided",",","each","value","will","be","considered","the","bound","for","a","feature",",","thus","the","shape","of","clip","values","needs","to","match","the","total","number","of","features",".",":","param","channels_first",":","Set","channels","first","or","last",".",":","param","preprocessing_defences",":","Preprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","postprocessing_defences",":","Postprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","preprocessing",":","Tuple","of","the","form","`","(","subtrahend",",","divisor",")","`","of","floats","or","`","np.ndarray","`","of","values","to","be","used","for","data","preprocessing",".","The","first","value","will","be","subtracted","from","the","input",".","The","input","will","then","be","divided","by","the","second","one",".",":","param","device_type",":","Type","of","device","to","be","used","for","model","and","tensors",",","if","`","cpu","`","run","on","CPU",",","if","`","gpu","`","run","on","GPU","if","available","otherwise","run","on","CPU","."]
code: def __init__(
      self,
      model,
      input_shape: Tuple[int, ...],
      clip_values: Optional["CLIP_VALUES_TYPE"] = None,
      channels_first: Optional[bool] = None,
      preprocessing_defences: Union[
          "Preprocessor", List["Preprocessor"], None
      ] = None,
      postprocessing_defences: Union[
          "Postprocessor", List["Postprocessor"], None
      ] = None,
      preprocessing: "PREPROCESSING_TYPE" = None,
      device_type: str = "gpu",
  ):
      """
      Initialization.
  
      :param model: GOTURN model.
      :param input_shape: Shape of one input sample as expected by the model, e.g. input_shape=(3, 227, 227).
      :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
             maximum values allowed for features. If floats are provided, these will be used as the range of all
             features. If arrays are provided, each value will be considered the bound for a feature, thus
             the shape of clip values needs to match the total number of features.
      :param channels_first: Set channels first or last.
      :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
      :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
      :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
             used for data preprocessing. The first value will be subtracted from the input. The input will then
             be divided by the second one.
      :param device_type: Type of device to be used for model and tensors, if `cpu` run on CPU, if `gpu` run on GPU
                          if available otherwise run on CPU.
      """
      import torch
  
      # Set device
      self._device: torch.device
      if device_type == "cpu" or not torch.cuda.is_available():
          self._device = torch.device("cpu")
      else:  # pragma: no cover
          cuda_idx = torch.cuda.current_device()
          self._device = torch.device(f"cuda:{cuda_idx}")
  
      model.to(self._device)
  
      super().__init__(
          model=model,
          clip_values=clip_values,
          channels_first=channels_first,
          preprocessing_defences=preprocessing_defences,
          postprocessing_defences=postprocessing_defences,
          preprocessing=preprocessing,
          device_type=device_type,
      )
      # got-10k toolkit
      # Tracker.__init__(self, name="PyTorchGoturn", is_deterministic=True)
      self.name = "PyTorchGoturn"
      self.is_deterministic = True
  
      self._input_shape = input_shape
  
      if self.clip_values is not None:
          if self.clip_values[0] != 0:  # pragma: no cover
              raise ValueError(
                  "This classifier requires un-normalized input images with clip_vales=(0, 255)."
              )
          if self.clip_values[1] not in [1, 255]:  # pragma: no cover
              raise ValueError(
                  "This classifier requires un-normalized input images with clip_vales=(0, 1) or "
                  "clip_vales=(0, 255)."
              )
  
      if self.postprocessing_defences is not None:  # pragma: no cover
          raise ValueError(
              "This estimator does not support `postprocessing_defences`."
          )
  
      self.attack_losses: Tuple[str, ...] = ("torch.nn.L1Loss",)
  
imports: import logging
  import time
  from typing import List, Dict, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.estimators.object_tracking.object_tracker import ObjectTrackerMixin
  from art.estimators.pytorch import PyTorchEstimator
label_desc: Use image node_id 1 to create a new PyTorchGoturn object from inherited base classes: ObjectTrackerMixin, PyTorchEstimator with example: obj = PyTorchGoturn(model, input_shape, clip_values, channels_first, preprocessing_defences, postprocessing_defences, preprocessing, device_type)