code: def calibrate_model(
      estimator,
      method: str = "sigmoid",
      calibrate_fold: Optional[Union[int, Any]] = 5,
      fold: Optional[Union[int, Any]] = None,
      round: int = 4,
      fit_kwargs: Optional[dict] = None,
      groups: Optional[Union[str, Any]] = None,
      verbose: bool = True,
      return_train_score: bool = False,
  ) -> Any:
      """
      This function calibrates the probability of a given estimator using isotonic
      or logistic regression. The output of this function is a score grid with CV
      scores by fold. Metrics evaluated during CV can be accessed using the
      ``get_metrics`` function. Custom metrics can be added or removed using
      ``add_metric`` and ``remove_metric`` function. The ouput of the original estimator
      and the calibrated estimator (created using this function) might not differ much.
      In order to see the calibration differences, use 'calibration' plot in ``plot_model``
      to see the difference before and after.
  
  
      Example
      -------
      >>> from pycaret.datasets import get_data
      >>> juice = get_data('juice')
      >>> from pycaret.classification import *
      >>> exp_name = setup(data = juice,  target = 'Purchase')
      >>> dt = create_model('dt')
      >>> calibrated_dt = calibrate_model(dt)
  
  
      estimator: scikit-learn compatible object
          Trained model object
  
  
      method: str, default = 'sigmoid'
          The method to use for calibration. Can be 'sigmoid' which corresponds to
          Platt's method or 'isotonic' which is a non-parametric approach.
  
  
      calibrate_fold: integer or scikit-learn compatible CV generator, default = 5
          Controls internal cross-validation. Can be an integer or a scikit-learn
          CV generator. If set to an integer, will use (Stratifed)KFold CV with
          that many folds. See scikit-learn documentation on Stacking for
          more details.
  
  
      fold: int or scikit-learn compatible CV generator, default = None
          Controls cross-validation. If None, the CV generator in the ``fold_strategy``
          parameter of the ``setup`` function is used. When an integer is passed,
          it is interpreted as the 'n_splits' parameter of the CV generator in the
          ``setup`` function.
  
  
      round: int, default = 4
          Number of decimal places the metrics in the score grid will be rounded to.
  
  
      fit_kwargs: dict, default = {} (empty dict)
          Dictionary of arguments passed to the fit method of the model.
  
  
      groups: str or array-like, with shape (n_samples,), default = None
          Optional group labels when GroupKFold is used for the cross validation.
          It takes an array with shape (n_samples, ) where n_samples is the number
          of rows in training dataset. When string is passed, it is interpreted as
          the column name in the dataset containing group labels.
  
  
      verbose: bool, default = True
          Score grid is not printed when verbose is set to False.
  
  
      return_train_score: bool, default = False
          If False, returns the CV Validation scores only.
          If True, returns the CV training scores along with the CV validation scores.
          This is useful when the user wants to do bias-variance tradeoff. A high CV
          training score with a low corresponding CV validation score indicates overfitting.
  
  
      Returns:
          Trained Model
  
  
      Warnings
      --------
      - Avoid isotonic calibration with too few calibration samples (< 1000) since it
        tends to overfit.
  
      """
  
      return _CURRENT_EXPERIMENT.calibrate_model(
          estimator=estimator,
          method=method,
          calibrate_fold=calibrate_fold,
          fold=fold,
          round=round,
          fit_kwargs=fit_kwargs,
          groups=groups,
          verbose=verbose,
          return_train_score=return_train_score,
      )
  
imports: import logging
  import os
  from typing import Any, BinaryIO, Callable, Dict, List, Optional, Union
  import pandas
  from joblib.memory import Memory
  from pycaret.classification.oop import ClassificationExperiment
  from pycaret.internal.parallel.parallel_backend import ParallelBackend
  from pycaret.loggers.base_logger import BaseLogger
  from pycaret.utils.constants import DATAFRAME_LIKE, SEQUENCE_LIKE, TARGET_LIKE
  from pycaret.utils.generic import check_if_global_is_not_none
label_desc: Use image node_id 13 for calling a global function with example usage: calibrate_model(estimator, method, calibrate_fold, fold, round, fit_kwargs, groups, verbose, return_train_score) and returns: _CURRENT_EXPERIMENT