code: def _specificity_at_sensitivity(
      specificity: Tensor,
      sensitivity: Tensor,
      thresholds: Tensor,
      min_sensitivity: float,
  ) -> Tuple[Tensor, Tensor]:
      # get indices where sensitivity is greater than min_sensitivity
      indices = sensitivity >= min_sensitivity
  
      # if no indices are found, max_spec, best_threshold = 0.0, 1e6
      if not indices.any():
          max_spec = torch.tensor(
              0.0, device=specificity.device, dtype=specificity.dtype
          )
          best_threshold = torch.tensor(
              1e6, device=thresholds.device, dtype=thresholds.dtype
          )
      else:
          # redefine specificity, sensitivity and threshold tensor based on indices
          specificity, sensitivity, thresholds = (
              specificity[indices],
              sensitivity[indices],
              thresholds[indices],
          )
  
          # get argmax
          idx = torch.argmax(specificity)
  
          # get max_spec and best_threshold
          max_spec, best_threshold = specificity[idx], thresholds[idx]
  
      return max_spec, best_threshold
  
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.classification.precision_recall_curve import _binary_precision_recall_curve_arg_validation, _binary_precision_recall_curve_format, _binary_precision_recall_curve_tensor_validation, _binary_precision_recall_curve_update, _multiclass_precision_recall_curve_arg_validation, _multiclass_precision_recall_curve_format, _multiclass_precision_recall_curve_tensor_validation, _multiclass_precision_recall_curve_update, _multilabel_precision_recall_curve_arg_validation, _multilabel_precision_recall_curve_format, _multilabel_precision_recall_curve_tensor_validation, _multilabel_precision_recall_curve_update
  from torchmetrics.functional.classification.roc import _binary_roc_compute, _multiclass_roc_compute, _multilabel_roc_compute
  from torchmetrics.utilities.enums import ClassificationTask
label_desc: Use image node_id 2 for calling a global function with example usage: _specificity_at_sensitivity(specificity, sensitivity, thresholds, min_sensitivity) and returns: max_spec,  best_threshold