code: def _safe_tags(estimator, key=None):
      """Safely get estimator tags.
  
      :class:`~sklearn.BaseEstimator` provides the estimator tags machinery.
      However, if an estimator does not inherit from this base class, we should
      fall-back to the default tags.
  
      For scikit-learn built-in estimators, we should still rely on
      `self._get_tags()`. `_safe_tags(est)` should be used when we are not sure
      where `est` comes from: typically `_safe_tags(self.base_estimator)` where
      `self` is a meta-estimator, or in the common checks.
  
      Parameters
      ----------
      estimator : estimator object
          The estimator from which to get the tag.
  
      key : str, default=None
          Tag name to get. By default (`None`), all tags are returned.
  
      Returns
      -------
      tags : dict or tag value
          The estimator tags. A single value is returned if `key` is not None.
      """
      if hasattr(estimator, "_get_tags"):
          tags_provider = "_get_tags()"
          tags = estimator._get_tags()
      elif hasattr(estimator, "_more_tags"):
          tags_provider = "_more_tags()"
          tags = {**_DEFAULT_TAGS, **estimator._more_tags()}
      else:
          tags_provider = "_DEFAULT_TAGS"
          tags = _DEFAULT_TAGS
  
      if key is not None:
          if key not in tags:
              raise ValueError(
                  f"The key {key} is not defined in {tags_provider} for the "
                  f"class {estimator.__class__.__name__}."
              )
          return tags[key]
      return tags
  
imports: import functools
  import logging
  import numbers
  import time
  import warnings
  from collections import Counter
  from contextlib import suppress
  from itertools import compress
  from traceback import format_exc
  import numpy
  import scipy.sparse
  from catboost import CatBoostClassifier, CatBoostRegressor
  from joblib import Parallel, logger
  from scipy.sparse import issparse
  from sklearn import config_context, get_config
  from sklearn.base import clone, is_classifier
  from sklearn.exceptions import FitFailedWarning, NotFittedError
  from sklearn.metrics import check_scoring
  from sklearn.metrics._scorer import _MultimetricScorer
  from sklearn.model_selection import check_cv
  from sklearn.utils.fixes import np_version, parse_version
  from sklearn.utils.validation import indexable
label_desc: Use image node_id 11 for calling a global function with example usage: _safe_tags(estimator, key) and returns: tags, tags