class_docstr: Flip Rate metrics.
  
  Proportion of flip counts (total, positive to negative and negative to
  positive) to number of examples.
  It calculates:
  - Total Flip Count / Total Example Count
  - Positive to Negative Flip Count / Total Example Count
  - Negative to Positive Flip Count / Total Example Count
docstr: Initializes flip rate metrics.
  
  Args:
    counterfactual_prediction_key: Prediction label key for counterfactual
      example to be used to measure the flip count. Defaults to None which
        indicates that the counterfactual_prediction_key should be extracted
        from the baseline model spec.
    name: Metric name.
    thresholds: Thresholds to be used to measure flips.
    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.
docstr_tok: ["Initializes","flip","rate","metrics",".","Args",":","counterfactual_prediction_key",":","Prediction","label","key","for","counterfactual","example","to","be","used","to","measure","the","flip","count",".","Defaults","to","None","which","indicates","that","the","counterfactual_prediction_key","should","be","extracted","from","the","baseline","model","spec",".","name",":","Metric","name",".","thresholds",":","Thresholds","to","be","used","to","measure","flips",".","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","."]
code: def __init__(
      self,
      counterfactual_prediction_key: str,
      name: str = FLIP_RATE_NAME,
      thresholds: Sequence[float] = flip_count.DEFAULT_THRESHOLDS,
      example_id_key: Optional[str] = None,
      example_ids_count: int = flip_count.DEFAULT_NUM_EXAMPLE_IDS,
  ):
      """Initializes flip rate metrics.
  
      Args:
        counterfactual_prediction_key: Prediction label key for counterfactual
          example to be used to measure the flip count. Defaults to None which
            indicates that the counterfactual_prediction_key should be extracted
            from the baseline model spec.
        name: Metric name.
        thresholds: Thresholds to be used to measure flips.
        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.
      """
      super().__init__(
          metric_util.merge_per_key_computations(_flip_rate),
          counterfactual_prediction_key=counterfactual_prediction_key,
          thresholds=thresholds,
          name=name,
          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_rate.py
imports: import random
  from typing import Dict, Optional, Sequence, Union
  import numpy
  from tensorflow_model_analysis.addons.fairness.metrics.counterfactual_fairness import flip_count
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 1 to create a new FlipRate object from inherited base classes: metric_types with example: obj = FlipRate(counterfactual_prediction_key, name, thresholds, example_id_key, example_ids_count)