code: def true_negative_rate_metric(
      y_true, y_pred, averaging_method: str = "per_class"
  ) -> Union[np.ndarray, float]:
      """Receive a metric which calculates true negative rate. Alternative name to the same metric is specificity.
  
      The rate is calculated as: True Negatives / (True Negatives + False Positives)
      Parameters
      ----------
      y_true : array-like of shape (n_samples, n_classes) or (n_samples) for binary
          The labels should be passed in a sequence of sequences, with the sequence for each sample being a binary vector,
          representing the presence of the i-th label in that sample (multi-label).
      y_pred : array-like of shape (n_samples, n_classes) or (n_samples) for binary
          The predictions should be passed in a sequence of sequences, with the sequence for each sample being a binary
          vector, representing the presence of the i-th label in that sample (multi-label).
      averaging_method : str, default: 'per_class'
          Determines which averaging method to apply, possible values are:
          'per_class': Return a np array with the scores for each class (sorted by class name).
          'binary': Returns the score for the positive class. Should be used only in binary classification cases.
          'micro': Returns the micro-averaged score.
          'macro': Returns the mean of scores per class.
          'weighted': Returns a weighted mean of scores based of the class size in y_true.
      Returns
      -------
      score : Union[np.ndarray, float]
          The score for the given metric.
      """
      # Convert multi label into single label
      if averaging_method != "binary":
          assert_multi_label_shape(y_true)
          assert_multi_label_shape(y_pred)
          classes = range(y_true.shape[1])
          y_true = np.argmax(y_true, axis=1)
          y_pred = np.argmax(y_pred, axis=1)
      else:
          assert_single_label_shape(y_true)
          assert_single_label_shape(y_pred)
          classes = [0, 1]
  
      if averaging_method == "micro":
          return _micro_true_negative_rate(y_true, y_pred, classes)
  
      scores_per_class = _true_negative_rate_per_class(
          y_true, y_pred, classes
      )
      weights = [sum(y_true == cls) for cls in classes]
      return averaging_mechanism(
          averaging_method, scores_per_class, weights
      )
  
file_path: deepchecks/deepchecks/tabular/metric_utils/additional_classification_metrics.py
imports: from typing import Union
  import numpy
  from sklearn.metrics import confusion_matrix, roc_auc_score
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.utils.metrics import averaging_mechanism
label_desc: Use image node_id 12 for calling a global function with example usage: true_negative_rate_metric(y_true, y_pred, averaging_method) and returns: averaging_mechanism, _micro_true_negative_rate