docstr: Fit the detector on reference data.
  
  Uses the choice of optimization method to fit the svm model to the data.
  
  Parameters
  ----------
  x_ref
      Reference data used to fit the detector.
  tol
      Convergence threshold used to fit the detector. Used for both ``'sgd'`` and ``'bgd'`` optimizations.
      Defaults to ``1e-3``.
  max_iter
      The maximum number of optimization steps. Used for both ``'sgd'`` and ``'bgd'`` optimizations.
  step_size_range
      The range of values to be considered for the gradient descent step size at each iteration. This is specified
      as a tuple of the form `(min_eta, max_eta)` and only used for the ``'bgd'`` optimization.
  n_step_sizes
      The number of step sizes in the defined range to be tested for loss reduction. This many points are spaced
      evenly along the range in log space. This is only used for the ``'bgd'`` optimization.
  n_iter_no_change
      The number of iterations over which the loss must decrease by `tol` in order for optimization to continue.
      This is only used for the ``'bgd'`` optimization..
  verbose
      Verbosity level during training. ``0`` is silent, ``1`` prints fit status. If using `bgd`, fit displays a
      progress bar. Otherwise, if using `sgd` then we output the Sklearn `SGDOneClassSVM.fit()` logs.
  
  Returns
  -------
  Dictionary with fit results. The dictionary contains the following keys depending on the optimization used:
      - converged: `bool` indicating whether training converged.
      - n_iter: number of iterations performed.
      - lower_bound: loss lower bound. Only returned for the `bgd`.
docstr_tok: ["Fit","the","detector","on","reference","data",".","Uses","the","choice","of","optimization","method","to","fit","the","svm","model","to","the","data",".","Parameters","--","--","--","--","--","x_ref","Reference","data","used","to","fit","the","detector",".","tol","Convergence","threshold","used","to","fit","the","detector",".","Used","for","both","``","'sgd","'","``","and","``","'bgd","'","``","optimizations",".","Defaults","to","``","1e-3","``",".","max_iter","The","maximum","number","of","optimization","steps",".","Used","for","both","``","'sgd","'","``","and","``","'bgd","'","``","optimizations",".","step_size_range","The","range","of","values","to","be","considered","for","the","gradient","descent","step","size","at","each","iteration",".","This","is","specified","as","a","tuple","of","the","form","`","(","min_eta",",","max_eta",")","`","and","only","used","for","the","``","'bgd","'","``","optimization",".","n_step_sizes","The","number","of","step","sizes","in","the","defined","range","to","be","tested","for","loss","reduction",".","This","many","points","are","spaced","evenly","along","the","range","in","log","space",".","This","is","only","used","for","the","``","'bgd","'","``","optimization",".","n_iter_no_change","The","number","of","iterations","over","which","the","loss","must","decrease","by","`","tol","`","in","order","for","optimization","to","continue",".","This","is","only","used","for","the","``","'bgd","'","``","optimization","..","verbose","Verbosity","level","during","training",".","``","0","``","is","silent",",","``","1","``","prints","fit","status",".","If","using","`","bgd","`",",","fit","displays","a","progress","bar",".","Otherwise",",","if","using","`","sgd","`","then","we","output","the","Sklearn","`","SGDOneClassSVM.fit","(",")","`","logs",".","Returns","--","--","--","-","Dictionary","with","fit","results",".","The","dictionary","contains","the","following","keys","depending","on","the","optimization","used",":","-","converged",":","`","bool","`","indicating","whether","training","converged",".","-","n_iter",":","number","of","iterations","performed",".","-","lower_bound",":","loss","lower","bound",".","Only","returned","for","the","`","bgd","`","."]
code: def fit(
      self,
      x_ref: np.ndarray,
      tol: float = 1e-6,
      max_iter: int = 1000,
      step_size_range: Tuple[float, float] = (1e-8, 1.0),
      n_step_sizes: int = 16,
      n_iter_no_change: int = 25,
      verbose: int = 0,
  ) -> None:
      """Fit the detector on reference data.
  
      Uses the choice of optimization method to fit the svm model to the data.
  
      Parameters
      ----------
      x_ref
          Reference data used to fit the detector.
      tol
          Convergence threshold used to fit the detector. Used for both ``'sgd'`` and ``'bgd'`` optimizations.
          Defaults to ``1e-3``.
      max_iter
          The maximum number of optimization steps. Used for both ``'sgd'`` and ``'bgd'`` optimizations.
      step_size_range
          The range of values to be considered for the gradient descent step size at each iteration. This is specified
          as a tuple of the form `(min_eta, max_eta)` and only used for the ``'bgd'`` optimization.
      n_step_sizes
          The number of step sizes in the defined range to be tested for loss reduction. This many points are spaced
          evenly along the range in log space. This is only used for the ``'bgd'`` optimization.
      n_iter_no_change
          The number of iterations over which the loss must decrease by `tol` in order for optimization to continue.
          This is only used for the ``'bgd'`` optimization..
      verbose
          Verbosity level during training. ``0`` is silent, ``1`` prints fit status. If using `bgd`, fit displays a
          progress bar. Otherwise, if using `sgd` then we output the Sklearn `SGDOneClassSVM.fit()` logs.
  
      Returns
      -------
      Dictionary with fit results. The dictionary contains the following keys depending on the optimization used:
          - converged: `bool` indicating whether training converged.
          - n_iter: number of iterations performed.
          - lower_bound: loss lower bound. Only returned for the `bgd`.
      """
      return self.backend.fit(
          self.backend._to_backend_dtype(x_ref),
          **self.backend.format_fit_kwargs(locals()),
      )
  
file_path: alibi-detect/alibi_detect/od/_svm.py
imports: from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple
  import numpy
  from alibi_detect.base import BaseDetector, FitMixin, ThresholdMixin, outlier_prediction_dict
  from alibi_detect.exceptions import _catch_error
  from alibi_detect.od.pytorch import SgdSVMTorch, BgdSVMTorch
  from alibi_detect.utils._types import Literal
  from alibi_detect.utils.frameworks import BackendValidator
  from alibi_detect.version import __version__
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 2 for calling the SVM obj's underlying member method code with example usage: obj.fit(x_ref, tol, max_iter, step_size_range, n_step_sizes, n_iter_no_change, verbose) and returns: self