code: def _boolean_flip_rates_computations(
      threshold: float,
      flip_rate_name: str,
      neg_to_neg_flip_rate_name: str,
      neg_to_pos_flip_rate_name: str,
      pos_to_neg_flip_rate_name: str,
      pos_to_pos_flip_rate_name: str,
      eval_config: Optional[config_pb2.EvalConfig],
      model_names: Optional[List[str]],
      output_names: Optional[List[str]] = None,
      sub_keys: Optional[List[metric_types.SubKey]] = None,
      example_weighted: bool = False,
  ) -> metric_types.MetricComputations:
      """Returns metric computations for SymmetricPredictionDifference.
  
      This is not meant to be used with merge_per_key_computations because we
      don't want to create computations for the baseline model, and we want to
      provide the baseline model name to each Combiner
  
      Args:
        threshold: The threshold to use for converting both the baseline and
          candidate predictions into boolean values that can be compared.
        flip_rate_name: Metric name for symmetric flip rate.
        neg_to_neg_flip_rate_name: Metric name for the negative-to-negative flip
          rate.
        neg_to_pos_flip_rate_name: Metric name for the negative-to-positive flip
          rate.
        pos_to_neg_flip_rate_name: Metric name for the positive-to-negative flip
          rate.
        pos_to_pos_flip_rate_name: Metric name for the positive-to-positive flip
          rate.
        eval_config: The EvalConfig for this TFMA evaluation. This is used to
          identify which model is the baseline.
        model_names: The set of models for which to compute this metric.
        output_names: The set of output names for which to compute this metric.
        sub_keys: The set of sub_key settings for which to compute this metric.
        example_weighted: Whether to compute this metric using example weights.
      """
      computations = []
      baseline_spec = model_util.get_baseline_model_spec(eval_config)
      baseline_model_name = (
          baseline_spec.name if baseline_spec else None
      )
      for model_name in model_names:
          if model_name == baseline_model_name:
              continue
          for output_name in output_names or [""]:
              for sub_key in sub_keys or [None]:
                  flip_rate_key = metric_types.MetricKey(
                      name=flip_rate_name,
                      model_name=model_name,
                      output_name=output_name,
                      sub_key=sub_key,
                      example_weighted=example_weighted,
                      is_diff=True,
                  )
                  neg_to_neg_key = metric_types.MetricKey(
                      name=neg_to_neg_flip_rate_name,
                      model_name=model_name,
                      output_name=output_name,
                      sub_key=sub_key,
                      example_weighted=example_weighted,
                      is_diff=True,
                  )
                  neg_to_pos_key = metric_types.MetricKey(
                      name=neg_to_pos_flip_rate_name,
                      model_name=model_name,
                      output_name=output_name,
                      sub_key=sub_key,
                      example_weighted=example_weighted,
                      is_diff=True,
                  )
                  pos_to_neg_key = metric_types.MetricKey(
                      name=pos_to_neg_flip_rate_name,
                      model_name=model_name,
                      output_name=output_name,
                      sub_key=sub_key,
                      example_weighted=example_weighted,
                      is_diff=True,
                  )
                  pos_to_pos_key = metric_types.MetricKey(
                      name=pos_to_pos_flip_rate_name,
                      model_name=model_name,
                      output_name=output_name,
                      sub_key=sub_key,
                      example_weighted=example_weighted,
                      is_diff=True,
                  )
                  computations.append(
                      metric_types.MetricComputation(
                          keys=[
                              flip_rate_key,
                              neg_to_neg_key,
                              neg_to_pos_key,
                              pos_to_neg_key,
                              pos_to_pos_key,
                          ],
                          preprocessors=None,
                          combiner=_BooleanFlipRatesCombiner(
                              threshold,
                              eval_config,
                              baseline_model_name,
                              model_name,
                              output_name,
                              flip_rate_key,
                              neg_to_neg_key,
                              neg_to_pos_key,
                              pos_to_neg_key,
                              pos_to_pos_key,
                              example_weighted,
                          ),
                      )
                  )
      return computations
  
file_path: model-analysis/tensorflow_model_analysis/metrics/flip_metrics.py
imports: import dataclasses
  from typing import Optional, Iterable, List
  import apache_beam
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import model_util
label_desc: Use image node_id 1 for calling a global function with example usage: _boolean_flip_rates_computations(threshold, flip_rate_name, neg_to_neg_flip_rate_name, neg_to_pos_flip_rate_name, pos_to_neg_flip_rate_name, pos_to_pos_flip_rate_name, eval_config, model_names, output_names, sub_keys, example_weighted) and returns: computations