class_docstr: Confusion matrix at thresholds.
  
  It computes the average precision of object detections for a single class and
  a single iou_threshold.
class_docstr_tok: ["Confusion","matrix","at","thresholds",".","It","computes","the","average","precision","of","object","detections","for","a","single","class","and","a","single","iou_threshold","."]
docstr: Returns computations for confusion matrix metric.
docstr_tok: ["Returns","computations","for","confusion","matrix","metric","."]
code: def _metric_computations(
      self,
      num_thresholds: Optional[int] = None,
      iou_threshold: Optional[float] = None,
      class_id: Optional[int] = None,
      class_weight: Optional[float] = None,
      max_num_detections: Optional[int] = None,
      area_range: Optional[Tuple[float, float]] = None,
      recall_thresholds: Optional[List[float]] = None,
      name: Optional[str] = None,
      model_name: str = "",
      output_name: str = "",
      example_weighted: bool = False,
      labels_to_stack: Optional[List[str]] = None,
      predictions_to_stack: Optional[List[str]] = None,
      num_detections_key: Optional[str] = None,
      allow_missing_key: bool = False,
  ) -> metric_types.MetricComputations:
      """Returns computations for confusion matrix metric."""
      metric_util.validate_object_detection_arguments(
          class_id=class_id,
          class_weight=class_weight,
          area_range=area_range,
          max_num_detections=max_num_detections,
          labels_to_stack=labels_to_stack,
          predictions_to_stack=predictions_to_stack,
          output_name=output_name,
      )
  
      key = metric_types.MetricKey(
          name=name,
          model_name=model_name,
          output_name=output_name,
          sub_key=None,
          example_weighted=example_weighted,
          aggregation_type=None,
      )
  
      if recall_thresholds is None:
          # If recall thresholds is not defined, initialize it as [0.0]
          recall_thresholds = [0.0]
  
      if num_thresholds is None:
          num_thresholds = 10000
      thresholds = (
          [1.0e-12]
          + [
              (i + 1) * 1.0 / (num_thresholds - 1)
              for i in range(num_thresholds - 2)
          ]
          + [1.0 - 1.0e-12]
      )
      # PrecisionAtRecall is a public function. To hide it from users who do not
      # need it, we make the name private with '_'.
      precision_at_recall_name = (
          metric_util.generate_private_name_from_arguments(
              confusion_matrix_metrics.PRECISION_AT_RECALL_NAME,
              recall=recall_thresholds,
              num_thresholds=num_thresholds,
              iou_threshold=iou_threshold,
              class_id=class_id,
              class_weight=class_weight,
              area_range=area_range,
              max_num_detections=max_num_detections,
              allow_missing_key=allow_missing_key,
          )
      )
  
      pr = object_detection_confusion_matrix_metrics.ObjectDetectionPrecisionAtRecall(
          recall=recall_thresholds,
          thresholds=thresholds,
          iou_threshold=iou_threshold,
          class_id=class_id,
          class_weight=class_weight,
          area_range=area_range,
          max_num_detections=max_num_detections,
          name=precision_at_recall_name,
          labels_to_stack=labels_to_stack,
          predictions_to_stack=predictions_to_stack,
          num_detections_key=num_detections_key,
          allow_missing_key=allow_missing_key,
      )
      computations = pr.computations(
          model_names=[model_name], output_names=[output_name]
      )
      precisions_key = computations[-1].keys[-1]
  
      def result(
          metrics: Dict[metric_types.MetricKey, Any]
      ) -> Dict[metric_types.MetricKey, Union[float, np.ndarray]]:
          value = np.nanmean(metrics[precisions_key])
          return {key: value}
  
      derived_computation = metric_types.DerivedMetricComputation(
          keys=[key], result=result
      )
      computations.append(derived_computation)
      return computations
  
imports: import logging
  import math
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  from tensorflow_model_analysis.metrics import confusion_matrix_metrics
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.metrics import object_detection_confusion_matrix_metrics
label_desc: Use image node_id 3 for calling the COCOAveragePrecision obj's underlying member method code with example usage: obj._metric_computations(num_thresholds, iou_threshold, class_id, class_weight, max_num_detections, area_range, recall_thresholds, name, model_name, output_name, example_weighted, labels_to_stack, predictions_to_stack, num_detections_key, allow_missing_key) and returns: computations, dict