class_docstr: Metric that computes bounded AUC for predictions in [0, 1].
  
  This metrics calculates the subgroup auc, the background positive subgroup
  negative auc and background negative subgroup positive auc. For more
  explanation about the concepts of these auc metrics, please refer to paper
  [Measuring and Mitigating Unintended Bias in Text
  Classification](https://ai.google/research/pubs/pub46743)
class_docstr_tok: ["Metric","that","computes","bounded","AUC","for","predictions","in","[","0",",","1","]",".","This","metrics","calculates","the","subgroup","auc",",","the","background","positive","subgroup","negative","auc","and","background","negative","subgroup","positive","auc",".","For","more","explanation","about","the","concepts","of","these","auc","metrics",",","please","refer","to","paper","[","Measuring","and","Mitigating","Unintended","Bias","in","Text","Classification","]","(","https",":","\/\/ai.google\/research\/pubs\/pub46743",")"]
code: def get_metric_ops(
      self,
      features_dict: types.TensorTypeMaybeDict,
      predictions_dict: types.TensorTypeMaybeDict,
      labels_dict: types.TensorTypeMaybeDict,
  ) -> Dict[str, Tuple[types.TensorType, types.TensorType]]:
      # Note that we have to squeeze predictions, labels, weights so they are all
      # N element vectors (otherwise some of them might be N x 1 tensors, and
      # multiplying a N element vector with a N x 1 tensor uses matrix
      # multiplication rather than element-wise multiplication).
      predictions, labels = self._get_labels_and_predictions(
          predictions_dict, labels_dict
      )
      predictions = post_export_metrics._flatten_to_one_dim(
          tf.cast(predictions, tf.float64)
      )
      labels = post_export_metrics._flatten_to_one_dim(
          tf.cast(labels, tf.float64)
      )
      weights = tf.ones_like(predictions)
      subgroup = post_export_metrics._flatten_to_one_dim(
          tf.cast(features_dict[self._subgroup_key], tf.bool)
      )
      if self._example_weight_key:
          weights = post_export_metrics._flatten_to_one_dim(
              tf.cast(
                  features_dict[self._example_weight_key], tf.float64
              )
          )
  
      (
          predictions,
          labels,
          weights,
      ) = post_export_metrics._create_predictions_labels_weights_for_fractional_labels(
          predictions, labels, weights
      )
      # To let subgroup tensor match the size with prediction, labels and weights
      # above.
      subgroup = tf.concat([subgroup, subgroup], axis=0)
  
      labels_bool = tf.cast(labels, tf.bool)
      pos_subgroup = tf.math.logical_and(labels_bool, subgroup)
      neg_subgroup = tf.math.logical_and(
          tf.math.logical_not(labels_bool), subgroup
      )
      pos_background = tf.math.logical_and(
          labels_bool, tf.math.logical_not(subgroup)
      )
      neg_background = tf.math.logical_and(
          tf.math.logical_not(labels_bool),
          tf.math.logical_not(subgroup),
      )
      bnsp = tf.math.logical_or(pos_subgroup, neg_background)
      bpsn = tf.math.logical_or(neg_subgroup, pos_background)
  
      ops_dict = {}
      # Add subgroup auc.
      ops_dict.update(
          post_export_metrics._build_auc_metrics_ops(
              self._subgroup_auc_metric,
              labels,
              predictions,
              tf.multiply(weights, tf.cast(subgroup, tf.float64)),
              self._num_buckets + 1,
              self._curve,
          )
      )
      # Add backgroup positive subgroup negative auc.
      ops_dict.update(
          post_export_metrics._build_auc_metrics_ops(
              self._bpsn_auc_metric,
              labels,
              predictions,
              tf.multiply(weights, tf.cast(bpsn, tf.float64)),
              self._num_buckets + 1,
              self._curve,
          )
      )
      # Add backgroup negative subgroup positive auc.
      ops_dict.update(
          post_export_metrics._build_auc_metrics_ops(
              self._bnsp_auc_metric,
              labels,
              predictions,
              tf.multiply(weights, tf.cast(bnsp, tf.float64)),
              self._num_buckets + 1,
              self._curve,
          )
      )
  
      return ops_dict
  
file_path: model-analysis/tensorflow_model_analysis/addons/fairness/post_export_metrics/fairness_indicators.py
imports: from typing import Any, Dict, List, Optional, Tuple
  import tensorflow
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  from tensorflow_model_analysis.post_export_metrics import post_export_metrics
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
label_desc: Use image node_id 3 for calling the _FairnessAuc obj's underlying member method code with example usage: obj.get_metric_ops(features_dict, predictions_dict, labels_dict) and returns: ops_dict