code: def _fit_classifier_calibrator_pair(
      estimator,
      X,
      y,
      train,
      test,
      method,
      classes,
      sample_weight=None,
      fit_params=None,
  ):
      """Fit a classifier/calibration pair on a given train/test split.
  
      Fit the classifier on the train set, compute its predictions on the test
      set and use the predictions as input to fit the calibrator along with the
      test labels.
  
      Parameters
      ----------
      estimator : estimator instance
          Cloned base estimator.
  
      X : array-like, shape (n_samples, n_features)
          Sample data.
  
      y : array-like, shape (n_samples,)
          Targets.
  
      train : ndarray, shape (n_train_indices,)
          Indices of the training subset.
  
      test : ndarray, shape (n_test_indices,)
          Indices of the testing subset.
  
      method : {'sigmoid', 'isotonic'}
          Method to use for calibration.
  
      classes : ndarray, shape (n_classes,)
          The target classes.
  
      sample_weight : array-like, default=None
          Sample weights for `X`.
  
      fit_params : dict, default=None
          Parameters to pass to the `fit` method of the underlying
          classifier.
  
      Returns
      -------
      calibrated_classifier : _CalibratedClassifier instance
      """
      fit_params_train = _check_fit_params(X, fit_params, train)
      X_train, y_train = _safe_indexing(X, train), _safe_indexing(
          y, train
      )
      X_test, y_test = _safe_indexing(X, test), _safe_indexing(y, test)
  
      estimator.fit(X_train, y_train, **fit_params_train)
  
      n_classes = len(classes)
      pred_method, method_name = _get_prediction_method(estimator)
      predictions = _compute_predictions(
          pred_method, method_name, X_test, n_classes
      )
  
      sw_test = (
          None
          if sample_weight is None
          else _safe_indexing(sample_weight, test)
      )
      calibrated_classifier = _fit_calibrator(
          estimator,
          predictions,
          y_test,
          classes,
          method,
          sample_weight=sw_test,
      )
      return calibrated_classifier
  
imports: import warnings
  from functools import partial
  from inspect import signature
  from math import log
  from numbers import Integral, Real
  import numpy
  from scipy.optimize import fmin_bfgs
  from scipy.special import expit, xlogy
  from sklearn.utils import Bunch
  from .base import BaseEstimator, ClassifierMixin, MetaEstimatorMixin, RegressorMixin, _fit_context, clone
  from .isotonic import IsotonicRegression
  from .model_selection import check_cv, cross_val_predict
  from .preprocessing import LabelEncoder, label_binarize
  from .svm import LinearSVC
  from .utils import _safe_indexing, column_or_1d, indexable
  from .utils._param_validation import HasMethods, Hidden, Interval, StrOptions, validate_params
  from .utils._plotting import _BinaryClassifierCurveDisplayMixin
  from .utils.metadata_routing import MetadataRouter, MethodMapping, _routing_enabled, process_routing
  from .utils.multiclass import check_classification_targets
  from .utils.parallel import Parallel, delayed
  from .utils.validation import _check_fit_params, _check_pos_label_consistency, _check_sample_weight, _num_samples, check_consistent_length, check_is_fitted
label_desc: Use image node_id 1 for calling a global function with example usage: _fit_classifier_calibrator_pair(estimator, X, y, train, test, method, classes, sample_weight, fit_params) and returns: calibrated_classifier