code: def fit(self, X, y=None):
      # Check input
      if self.check_input:
          check_array(X)
  
      # Check all values are positive
      if (X < 0).any().any():
          raise ValueError("All values in X should be positive")
  
      _, row_names, _, col_names = utils.make_labels_and_names(X)
  
      if isinstance(X, pd.DataFrame):
          X = X.to_numpy()
  
      if self.copy:
          X = np.copy(X)
  
      # Compute the correspondence matrix which contains the relative frequencies
      X = X.astype(float) / np.sum(X)
  
      # Compute row and column masses
      self.row_masses_ = pd.Series(X.sum(axis=1), index=row_names)
      self.col_masses_ = pd.Series(X.sum(axis=0), index=col_names)
  
      self.active_rows_ = self.row_masses_.index.unique()
      self.active_cols_ = self.col_masses_.index.unique()
  
      # Compute standardised residuals
      r = self.row_masses_.to_numpy()
      c = self.col_masses_.to_numpy()
      S = (
          sparse.diags(r**-0.5)
          @ (X - np.outer(r, c))
          @ sparse.diags(c**-0.5)
      )
  
      # Compute SVD on the standardised residuals
      self.svd_ = svd.compute_svd(
          X=S,
          n_components=min(self.n_components, min(X.shape) - 1),
          n_iter=self.n_iter,
          random_state=self.random_state,
          engine=self.engine,
      )
  
      # Compute total inertia
      self.total_inertia_ = np.einsum("ij,ji->", S, S.T)
  
      self.row_contributions_ = pd.DataFrame(
          sparse.diags(self.row_masses_.values)
          @ (
              # Same as row_coordinates(X)
              (
                  sparse.diags(self.row_masses_.values**-0.5)
                  @ self.svd_.U
                  @ sparse.diags(self.svd_.s)
              )
              ** 2
          )
          / self.eigenvalues_,
          index=self.row_masses_.index,
      )
  
      self.column_contributions_ = pd.DataFrame(
          sparse.diags(self.col_masses_.values)
          @ (
              # Same as col_coordinates(X)
              (
                  sparse.diags(self.col_masses_.values**-0.5)
                  @ self.svd_.V.T
                  @ sparse.diags(self.svd_.s)
              )
              ** 2
          )
          / self.eigenvalues_,
          index=self.col_masses_.index,
      )
  
      return self
  
imports: from __future__ import annotations
  import functools
  import altair
  import numpy
  import pandas
  from scipy import sparse
  from sklearn.utils import check_array
  from prince import svd, utils
label_desc: Use image node_id 2 for calling the CA obj's underlying member method code with example usage: obj.fit(X, y) and returns: self