code: def _relative_coefficient_of_discrimination(
      name: str = RELATIVE_COEFFICIENT_OF_DISCRIMINATION_NAME,
      eval_config: Optional[config_pb2.EvalConfig] = None,
      model_name: str = "",
      output_name: str = "",
      aggregation_type: Optional[metric_types.AggregationType] = None,
      class_weights: Optional[Dict[float, int]] = None,
      example_weighted: bool = False,
  ) -> metric_types.MetricComputations:
      """Returns metric computations for coefficient of discrimination."""
      key = metric_types.MetricKey(
          name=name,
          model_name=model_name,
          output_name=output_name,
          example_weighted=example_weighted,
      )
  
      # Compute shared tjur discimination metrics.
      computations = _tjur_discrimination(
          eval_config=eval_config,
          model_name=model_name,
          output_name=output_name,
          aggregation_type=aggregation_type,
          class_weights=class_weights,
          example_weighted=example_weighted,
      )
      # Shared metrics are based on a single computation and key.
      tjur_discrimination_key = computations[0].keys[0]
  
      def result(
          metrics: Dict[metric_types.MetricKey, Any]
      ) -> Dict[metric_types.MetricKey, float]:
          """Returns coefficient of discrimination."""
          metric = metrics[tjur_discrimination_key]
          if (
              metric.total_negative_weighted_labels == 0
              or metric.total_positive_weighted_labels == 0
              or metric.total_negative_weighted_predictions == 0
          ):
              value = float("nan")
          else:
              avg_pos_label = (
                  metric.total_positive_weighted_predictions
                  / metric.total_positive_weighted_labels
              )
              avg_neg_label = (
                  metric.total_negative_weighted_predictions
                  / metric.total_negative_weighted_labels
              )
              value = avg_pos_label / avg_neg_label
          return {key: value}
  
      derived_computation = metric_types.DerivedMetricComputation(
          keys=[key], result=result
      )
      computations.append(derived_computation)
      return computations
  
imports: from typing import Any, Dict, Iterable, Optional
  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
label_desc: Use image node_id 2 for calling a global function with example usage: _relative_coefficient_of_discrimination(name, eval_config, model_name, output_name, aggregation_type, class_weights, example_weighted) and returns: computations, dict