code: def compute_num_gen_TF_PN(
      X,
      y_true,
      y_score,
      w,
      feature_names,
      favorable_label,
      unfavorable_label,
      condition=None,
  ):
      """Compute the number of generalized true/false positives/negatives
      optionally conditioned on protected attributes. Generalized counts are based
      on scores and not on the hard predictions.
  
      Args:
          X (numpy.ndarray): Dataset features.
          y_true (numpy.ndarray): True label vector.
          y_score (numpy.ndarray): Predicted score vector. Values range from 0 to
              1. 0 implies prediction for unfavorable label and 1 implies
              prediction for favorable label.
          w (numpy.ndarray): Instance weight vector - the true and predicted
              datasets are supposed to have same instance level weights.
          feature_names (list): names of the features.
          favorable_label (float): Value of favorable/positive label.
          unfavorable_label (float): Value of unfavorable/negative label.
          condition (list(dict)): Same format as
              :func:`compute_boolean_conditioning_vector`.
  
      Returns:
          Number of positives/negatives (optionally conditioned).
      """
      # condition if necessary
      cond_vec = compute_boolean_conditioning_vector(
          X, feature_names, condition=condition
      )
  
      # to prevent broadcasts
      y_true = y_true.ravel()
      y_score = y_score.ravel()
      w = w.ravel()
  
      y_true_pos = np.logical_and(y_true == favorable_label, cond_vec)
      y_true_neg = np.logical_and(y_true == unfavorable_label, cond_vec)
  
      # Generalized true/false positives/negatives
      return dict(
          GTP=np.sum((w * y_score)[y_true_pos], dtype=np.float64),
          GFP=np.sum((w * y_score)[y_true_neg], dtype=np.float64),
          GTN=np.sum(
              (w * (1.0 - y_score))[y_true_neg], dtype=np.float64
          ),
          GFN=np.sum(
              (w * (1.0 - y_score))[y_true_pos], dtype=np.float64
          ),
      )
  
imports: import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: compute_num_gen_TF_PN(X, y_true, y_score, w, feature_names, favorable_label, unfavorable_label, condition) and returns: dict