docstr: Gaussian Mixture Model (GMM) outlier detector.
  
  The gaussian mixture model outlier detector fits a mixture of gaussian distributions to the reference data.
  Test points are scored via the negative log-likelihood under the corresponding density function.
  
  We support two backends: ``'pytorch'`` and ``'sklearn'``. The ``'pytorch'`` backend allows for GPU acceleration
  and uses gradient descent to fit the GMM. We recommend using the ``'pytorch'`` backend for large datasets. The
  ``'sklearn'`` backend is a pure python implementation and is recommended for smaller datasets.
  
  Parameters
  ----------
  n_components:
      The number of mixture components. Defaults to ``1``.
  backend
      Backend used for outlier detection. Defaults to ``'sklearn'``. Options are ``'pytorch'`` and ``'sklearn'``.
  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``. The device is only used if the ``'pytorch'`` backend is used. Defaults
      to ``None``.
  
  Raises
  ------
  NotImplementedError
      If choice of `backend` is not implemented.
docstr_tok: ["Gaussian","Mixture","Model","(","GMM",")","outlier","detector",".","The","gaussian","mixture","model","outlier","detector","fits","a","mixture","of","gaussian","distributions","to","the","reference","data",".","Test","points","are","scored","via","the","negative","log-likelihood","under","the","corresponding","density","function",".","We","support","two","backends",":","``","'pytorch","'","``","and","``","'sklearn","'","``",".","The","``","'pytorch","'","``","backend","allows","for","GPU","acceleration","and","uses","gradient","descent","to","fit","the","GMM",".","We","recommend","using","the","``","'pytorch","'","``","backend","for","large","datasets",".","The","``","'sklearn","'","``","backend","is","a","pure","python","implementation","and","is","recommended","for","smaller","datasets",".","Parameters","--","--","--","--","--","n_components",":","The","number","of","mixture","components",".","Defaults","to","``","1","``",".","backend","Backend","used","for","outlier","detection",".","Defaults","to","``","'sklearn","'","``",".","Options","are","``","'pytorch","'","``","and","``","'sklearn","'","``",".","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","``",".","The","device","is","only","used","if","the","``","'pytorch","'","``","backend","is","used",".","Defaults","to","``","None","``",".","Raises","--","--","--","NotImplementedError","If","choice","of","`","backend","`","is","not","implemented","."]
code: def __init__(
      self,
      n_components: int = 1,
      backend: Literal["pytorch", "sklearn"] = "sklearn",
      device: TorchDeviceType = None,
  ) -> None:
      """Gaussian Mixture Model (GMM) outlier detector.
  
      The gaussian mixture model outlier detector fits a mixture of gaussian distributions to the reference data.
      Test points are scored via the negative log-likelihood under the corresponding density function.
  
      We support two backends: ``'pytorch'`` and ``'sklearn'``. The ``'pytorch'`` backend allows for GPU acceleration
      and uses gradient descent to fit the GMM. We recommend using the ``'pytorch'`` backend for large datasets. The
      ``'sklearn'`` backend is a pure python implementation and is recommended for smaller datasets.
  
      Parameters
      ----------
      n_components:
          The number of mixture components. Defaults to ``1``.
      backend
          Backend used for outlier detection. Defaults to ``'sklearn'``. Options are ``'pytorch'`` and ``'sklearn'``.
      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``. The device is only used if the ``'pytorch'`` backend is used. Defaults
          to ``None``.
  
      Raises
      ------
      NotImplementedError
          If choice of `backend` is not implemented.
      """
      super().__init__()
  
      backend_str: str = backend.lower()
      BackendValidator(
          backend_options={
              "pytorch": ["pytorch"],
              "sklearn": ["sklearn"],
          },
          construct_name=self.__class__.__name__,
      ).verify_backend(backend_str)
  
      backend_cls = backends[backend]
      args: Dict[str, Any] = {"n_components": n_components}
      if backend == "pytorch":
          args["device"] = device
      self.backend = backend_cls(**args)
  
      # set metadata
      self.meta["detector_type"] = "outlier"
      self.meta["data_type"] = "numeric"
      self.meta["online"] = False
  
imports: from typing import Optional, Dict, Any
  import numpy
  from alibi_detect.utils._types import Literal
  from alibi_detect.base import outlier_prediction_dict
  from alibi_detect.base import BaseDetector, ThresholdMixin, FitMixin
  from alibi_detect.od.pytorch import GMMTorch
  from alibi_detect.od.sklearn import GMMSklearn
  from alibi_detect.utils.frameworks import BackendValidator
  from alibi_detect.version import __version__
  from alibi_detect.exceptions import _catch_error
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 1 to create a new GMM object from inherited base classes: BaseDetector, ThresholdMixin, FitMixin with example: obj = GMM(n_components, backend, device)