class_docstr: Principle Component Analysis (PCA).
  
  Args:
      n_components (float): Number of components. Can be either integer number of components
        or a ratio between 0-1.
docstr: Fits the PCA model to the dataset.
  
  Args:
    dataset (Tensor): Input dataset to fit the model.
code: def fit(self, dataset: Tensor) -> None:
      """Fits the PCA model to the dataset.
  
      Args:
        dataset (Tensor): Input dataset to fit the model.
      """
      mean = dataset.mean(dim=0)
      dataset -= mean
  
      _, sig, v_h = torch.linalg.svd(
          dataset.double(), full_matrices=False
      )
      num_components: int
      if self.n_components <= 1:
          variance_ratios = torch.cumsum(sig * sig, dim=0) / torch.sum(
              sig * sig
          )
          num_components = torch.nonzero(
              variance_ratios >= self.n_components
          )[0]
      else:
          num_components = int(self.n_components)
  
      self.num_components = Tensor([num_components])
  
      self.singular_vectors = v_h.transpose(-2, -1)[
          :, :num_components
      ].float()
      self.singular_values = sig[:num_components].float()
      self.mean = mean
  
file_path: anomalib/src/anomalib/models/components/dimensionality_reduction/pca.py
imports: from __future__ import annotations
  import torch
  from torch import Tensor
  from anomalib.models.components.base import DynamicBufferModule
label_desc: Use image node_id 2 for calling the PCA obj's underlying member method code with example usage: obj.fit(dataset) without return types