code: def _binary_clf_curve(
      y_true, y_score, pos_label=None, sample_weight=None
  ):
      """Calculate true and false positives per binary classification threshold.
  
      Parameters
      ----------
      y_true : ndarray of shape (n_samples,)
          True targets of binary classification.
  
      y_score : ndarray of shape (n_samples,)
          Estimated probabilities or output of a decision function.
  
      pos_label : int, float, bool or str, default=None
          The label of the positive class.
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights.
  
      Returns
      -------
      fps : ndarray of shape (n_thresholds,)
          A count of false positives, at index i being the number of negative
          samples assigned a score >= thresholds[i]. The total number of
          negative samples is equal to fps[-1] (thus true negatives are given by
          fps[-1] - fps).
  
      tps : ndarray of shape (n_thresholds,)
          An increasing count of true positives, at index i being the number
          of positive samples assigned a score >= thresholds[i]. The total
          number of positive samples is equal to tps[-1] (thus false negatives
          are given by tps[-1] - tps).
  
      thresholds : ndarray of shape (n_thresholds,)
          Decreasing score values.
      """
      # Check to make sure y_true is valid
      y_type = type_of_target(y_true, input_name="y_true")
      if not (
          y_type == "binary"
          or (y_type == "multiclass" and pos_label is not None)
      ):
          raise ValueError("{0} format is not supported".format(y_type))
  
      check_consistent_length(y_true, y_score, sample_weight)
      y_true = column_or_1d(y_true)
      y_score = column_or_1d(y_score)
      assert_all_finite(y_true)
      assert_all_finite(y_score)
  
      # Filter out zero-weighted samples, as they should not impact the result
      if sample_weight is not None:
          sample_weight = column_or_1d(sample_weight)
          sample_weight = _check_sample_weight(sample_weight, y_true)
          nonzero_weight_mask = sample_weight != 0
          y_true = y_true[nonzero_weight_mask]
          y_score = y_score[nonzero_weight_mask]
          sample_weight = sample_weight[nonzero_weight_mask]
  
      pos_label = _check_pos_label_consistency(pos_label, y_true)
  
      # make y_true a boolean vector
      y_true = y_true == pos_label
  
      # sort scores and corresponding truth values
      desc_score_indices = np.argsort(y_score, kind="mergesort")[::-1]
      y_score = y_score[desc_score_indices]
      y_true = y_true[desc_score_indices]
      if sample_weight is not None:
          weight = sample_weight[desc_score_indices]
      else:
          weight = 1.0
  
      # y_score typically has many tied values. Here we extract
      # the indices associated with the distinct values. We also
      # concatenate a value for the end of the curve.
      distinct_value_indices = np.where(np.diff(y_score))[0]
      threshold_idxs = np.r_[distinct_value_indices, y_true.size - 1]
  
      # accumulate the true positives with decreasing threshold
      tps = stable_cumsum(y_true * weight)[threshold_idxs]
      if sample_weight is not None:
          # express fps as a cumsum to ensure fps is increasing even in
          # the presence of floating point errors
          fps = stable_cumsum((1 - y_true) * weight)[threshold_idxs]
      else:
          fps = 1 + threshold_idxs - tps
      return fps, tps, y_score[threshold_idxs]
  
imports: import warnings
  from functools import partial
  from numbers import Integral, Real
  import numpy
  from scipy.sparse import csr_matrix, issparse
  from scipy.stats import rankdata
  from ..exceptions import UndefinedMetricWarning
  from ..preprocessing import label_binarize
  from ..utils import assert_all_finite, check_array, check_consistent_length, column_or_1d
  from ..utils._encode import _encode, _unique
  from ..utils._param_validation import Interval, StrOptions, validate_params
  from ..utils.extmath import stable_cumsum
  from ..utils.fixes import trapezoid
  from ..utils.multiclass import type_of_target
  from ..utils.sparsefuncs import count_nonzero
  from ..utils.validation import _check_pos_label_consistency, _check_sample_weight
  from ._base import _average_binary_score, _average_multiclass_ovo_score
label_desc: Use image node_id 7 for calling a global function with example usage: _binary_clf_curve(y_true, y_score, pos_label, sample_weight) and returns: fps,  tps,  y_score