docstr: Pytorch backend for the Support Vector Machine (SVM) outlier detector.
  
  Parameters
  ----------
  nu
      The proportion of the training data that should be considered outliers. Note that this does
      not necessarily correspond to the false positive rate on test data, which is still defined when
      calling the `infer_threshold` method.
  kernel
      Kernel function to use for outlier detection.
  n_components
      Number of components in the Nystroem approximation, by default uses all of them.
  device
      Device type used. The default tries to use the GPU and falls back on CPU if needed.
      Can be specified by passing either ``'cuda'``, ``'gpu'``, ``'cpu'`` or an instance of
      ``torch.device``.
docstr_tok: ["Pytorch","backend","for","the","Support","Vector","Machine","(","SVM",")","outlier","detector",".","Parameters","--","--","--","--","--","nu","The","proportion","of","the","training","data","that","should","be","considered","outliers",".","Note","that","this","does","not","necessarily","correspond","to","the","false","positive","rate","on","test","data",",","which","is","still","defined","when","calling","the","`","infer_threshold","`","method",".","kernel","Kernel","function","to","use","for","outlier","detection",".","n_components","Number","of","components","in","the","Nystroem","approximation",",","by","default","uses","all","of","them",".","device","Device","type","used",".","The","default","tries","to","use","the","GPU","and","falls","back","on","CPU","if","needed",".","Can","be","specified","by","passing","either","``","'cuda","'","``",",","``","'gpu","'","``",",","``","'cpu","'","``","or","an","instance","of","``","torch.device","``","."]
code: def __init__(
      self,
      nu: float,
      kernel: "torch.nn.Module" = None,
      n_components: Optional[int] = None,
      device: TorchDeviceType = None,
  ):
      """Pytorch backend for the Support Vector Machine (SVM) outlier detector.
  
      Parameters
      ----------
      nu
          The proportion of the training data that should be considered outliers. Note that this does
          not necessarily correspond to the false positive rate on test data, which is still defined when
          calling the `infer_threshold` method.
      kernel
          Kernel function to use for outlier detection.
      n_components
          Number of components in the Nystroem approximation, by default uses all of them.
      device
          Device type used. The default tries to use the GPU and falls back on CPU if needed.
          Can be specified by passing either ``'cuda'``, ``'gpu'``, ``'cpu'`` or an instance of
          ``torch.device``.
      """
      super().__init__(device=device)
      self.n_components = n_components
      if kernel is None:
          kernel = GaussianRBF()
      self.kernel = kernel
      self.nystroem = _Nystroem(self.kernel, self.n_components)
      self.nu = nu
  
imports: import warnings
  from typing import Callable, Dict, Optional, Tuple
  import numpy
  import torch
  from sklearn.linear_model import SGDOneClassSVM
  from sklearn.utils.extmath import safe_sparse_dot
  from tqdm import tqdm
  from typing_extensions import Self
  from alibi_detect.od.pytorch.base import TorchOutlierDetector
  from alibi_detect.utils.pytorch.losses import hinge_loss
  from alibi_detect.utils.pytorch.kernels import GaussianRBF
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 1 to create a new SVMTorch object from inherited base classes: TorchOutlierDetector with example: obj = SVMTorch(nu, kernel, n_components, device)