docstr: Compute the principal components of the reference data.
  
  We compute the principal components of the reference data using the covariance matrix and then
  remove the largest `n_components` eigenvectors. The remaining eigenvectors correspond to the
  invariant dimensions of the data. Changes in these dimensions are used to compute the outlier
  score which is the distance to the principal subspace spanned by the first `n_components`
  eigenvectors.
  
  Parameters
  ----------
  x
      The reference data.
  
  Returns
  -------
  The principal components of the reference data.
  
  Raises
  ------
  ValueError
      If `n_components` is greater than or equal to number of features
docstr_tok: ["Compute","the","principal","components","of","the","reference","data",".","We","compute","the","principal","components","of","the","reference","data","using","the","covariance","matrix","and","then","remove","the","largest","`","n_components","`","eigenvectors",".","The","remaining","eigenvectors","correspond","to","the","invariant","dimensions","of","the","data",".","Changes","in","these","dimensions","are","used","to","compute","the","outlier","score","which","is","the","distance","to","the","principal","subspace","spanned","by","the","first","`","n_components","`","eigenvectors",".","Parameters","--","--","--","--","--","x","The","reference","data",".","Returns","--","--","--","-","The","principal","components","of","the","reference","data",".","Raises","--","--","--","ValueError","If","`","n_components","`","is","greater","than","or","equal","to","number","of","features"]
code: def _fit(self, x: torch.Tensor) -> torch.Tensor:
      """Compute the principal components of the reference data.
  
      We compute the principal components of the reference data using the covariance matrix and then
      remove the largest `n_components` eigenvectors. The remaining eigenvectors correspond to the
      invariant dimensions of the data. Changes in these dimensions are used to compute the outlier
      score which is the distance to the principal subspace spanned by the first `n_components`
      eigenvectors.
  
      Parameters
      ----------
      x
          The reference data.
  
      Returns
      -------
      The principal components of the reference data.
  
      Raises
      ------
      ValueError
          If `n_components` is greater than or equal to number of features
      """
      if self.n_components >= x.shape[1]:
          raise ValueError(
              "n_components must be less than the number of features."
          )
  
      self.x_ref_mean = x.mean(0)
      x -= self.x_ref_mean
      cov_mat = (x.t() @ x) / (len(x) - 1)
      _, V = torch.linalg.eigh(cov_mat)
      return V[:, : -self.n_components]
  
imports: from typing import Optional, Callable
  import torch
  from alibi_detect.od.pytorch.base import TorchOutlierDetector
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 2 for calling the LinearPCATorch obj's underlying member method code with example usage: obj._fit(x) and returns: V