class_docstr: Flip count metric.
  
  Calculates the number of flips in prediction values for original and
  counterfactual examples (which have sensitive terms swapped, ablated etc.)
  
  It calculates:
  - positive to negative flips
  - negative to positive flips
  
  Other than flip counts, it also provides sample of example ids for which
  those flips are happening.
docstr: Initializes flip count.
  
  Args:
    counterfactual_prediction_key: Prediction label key for counterfactual
      example to be used to measure the flip count if the counterfactual
      example is contained within features. Otherwise the baseline model
      prediction will be used as the counterfactual.
    example_id_key: Feature key containing example id.
    example_ids_count: Max number of example ids to be extracted for false
      positives and false negatives.
    name: Metric name.
    thresholds: Thresholds to be used to measure flips.
docstr_tok: ["Initializes","flip","count",".","Args",":","counterfactual_prediction_key",":","Prediction","label","key","for","counterfactual","example","to","be","used","to","measure","the","flip","count","if","the","counterfactual","example","is","contained","within","features",".","Otherwise","the","baseline","model","prediction","will","be","used","as","the","counterfactual",".","example_id_key",":","Feature","key","containing","example","id",".","example_ids_count",":","Max","number","of","example","ids","to","be","extracted","for","false","positives","and","false","negatives",".","name",":","Metric","name",".","thresholds",":","Thresholds","to","be","used","to","measure","flips","."]
code: def __init__(
      self,
      counterfactual_prediction_key: Optional[str] = None,
      example_id_key: Optional[str] = None,
      example_ids_count: int = DEFAULT_NUM_EXAMPLE_IDS,
      name: str = FLIP_COUNT_NAME,
      thresholds: Sequence[float] = DEFAULT_THRESHOLDS,
  ):
      """Initializes flip count.
  
      Args:
        counterfactual_prediction_key: Prediction label key for counterfactual
          example to be used to measure the flip count if the counterfactual
          example is contained within features. Otherwise the baseline model
          prediction will be used as the counterfactual.
        example_id_key: Feature key containing example id.
        example_ids_count: Max number of example ids to be extracted for false
          positives and false negatives.
        name: Metric name.
        thresholds: Thresholds to be used to measure flips.
      """
      super().__init__(
          metric_util.merge_per_key_computations(flip_count),
          name=name,
          thresholds=thresholds,
          counterfactual_prediction_key=counterfactual_prediction_key,
          example_id_key=example_id_key,
          example_ids_count=example_ids_count,
      )
  
file_path: model-analysis/tensorflow_model_analysis/addons/fairness/metrics/counterfactual_fairness/flip_count.py
imports: import collections
  from typing import Any, Dict, List, Optional, Iterator, Sequence, Tuple
  import numpy
  from tensorflow_model_analysis.metrics import binary_confusion_matrices
  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
  from tensorflow_model_analysis.utils import util
label_desc: Use image node_id 1 to create a new FlipCount object from inherited base classes: metric_types with example: obj = FlipCount(counterfactual_prediction_key, example_id_key, example_ids_count, name, thresholds)