code: def _cov(X, shrinkage=None, covariance_estimator=None):
      """Estimate covariance matrix (using optional covariance_estimator).
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Input data.
  
      shrinkage : {'empirical', 'auto'} or float, default=None
          Shrinkage parameter, possible values:
            - None or 'empirical': no shrinkage (default).
            - 'auto': automatic shrinkage using the Ledoit-Wolf lemma.
            - float between 0 and 1: fixed shrinkage parameter.
  
          Shrinkage parameter is ignored if  `covariance_estimator`
          is not None.
  
      covariance_estimator : estimator, default=None
          If not None, `covariance_estimator` is used to estimate
          the covariance matrices instead of relying on the empirical
          covariance estimator (with potential shrinkage).
          The object should have a fit method and a ``covariance_`` attribute
          like the estimators in :mod:`sklearn.covariance``.
          if None the shrinkage parameter drives the estimate.
  
          .. versionadded:: 0.24
  
      Returns
      -------
      s : ndarray of shape (n_features, n_features)
          Estimated covariance matrix.
      """
      if covariance_estimator is None:
          shrinkage = "empirical" if shrinkage is None else shrinkage
          if isinstance(shrinkage, str):
              if shrinkage == "auto":
                  sc = StandardScaler()  # standardize features
                  X = sc.fit_transform(X)
                  s = ledoit_wolf(X)[0]
                  # rescale
                  s = (
                      sc.scale_[:, np.newaxis]
                      * s
                      * sc.scale_[np.newaxis, :]
                  )
              elif shrinkage == "empirical":
                  s = empirical_covariance(X)
          elif isinstance(shrinkage, Real):
              s = shrunk_covariance(empirical_covariance(X), shrinkage)
      else:
          if shrinkage is not None and shrinkage != 0:
              raise ValueError(
                  "covariance_estimator and shrinkage parameters "
                  "are not None. Only one of the two can be set."
              )
          covariance_estimator.fit(X)
          if not hasattr(covariance_estimator, "covariance_"):
              raise ValueError(
                  "%s does not have a covariance_ attribute"
                  % covariance_estimator.__class__.__name__
              )
          s = covariance_estimator.covariance_
      return s
  
imports: import warnings
  from numbers import Integral, Real
  import numpy
  import scipy.linalg
  from scipy import linalg
  from .base import BaseEstimator, ClassifierMixin, ClassNamePrefixFeaturesOutMixin, TransformerMixin, _fit_context
  from .covariance import empirical_covariance, ledoit_wolf, shrunk_covariance
  from .linear_model._base import LinearClassifierMixin
  from .preprocessing import StandardScaler
  from .utils._array_api import _expit, device, get_namespace, size
  from .utils._param_validation import HasMethods, Interval, StrOptions
  from .utils.extmath import softmax
  from .utils.multiclass import check_classification_targets, unique_labels
  from .utils.validation import check_is_fitted
label_desc: Use image node_id 1 for calling a global function with example usage: _cov(X, shrinkage, covariance_estimator) and returns: s