class_docstr: Mean average precision for object detections.
  
  It calculates the mean average precision metric for object detections. It
  averages COCOAveragePrecision over multiple classes and IoU thresholds.
class_docstr_tok: ["Mean","average","precision","for","object","detections",".","It","calculates","the","mean","average","precision","metric","for","object","detections",".","It","averages","COCOAveragePrecision","over","multiple","classes","and","IoU","thresholds","."]
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_thresholds: Optional[List[float]] = None,
      class_ids: Optional[List[int]] = None,
      class_weights: Optional[List[float]] = None,
      max_num_detections: Optional[int] = None,
      area_range: Optional[Tuple[float, float]] = None,
      recalls: Optional[List[float]] = None,
      num_recalls: Optional[int] = 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,
      **kwargs,
  ) -> metric_types.MetricComputations:
      """Returns computations for confusion matrix metric."""
  
      metric_util.validate_object_detection_arguments(
          class_id=class_ids,
          class_weight=class_weights,
          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,
      )
  
      # set default value according to COCO metrics
      if iou_thresholds is None:
          iou_thresholds = np.linspace(0.5, 0.95, 10)
      if class_weights is None:
          class_weights = [1.0] * len(class_ids)
  
      key = metric_types.MetricKey(
          name=name,
          model_name=model_name,
          output_name=output_name,
          sub_key=None,
          example_weighted=example_weighted,
          aggregation_type=None,
      )
  
      computations = []
      precisions_keys = []
      for iou_threshold in iou_thresholds:
          for class_id, class_weight in zip(class_ids, class_weights):
              average_precision_name = (
                  metric_util.generate_private_name_from_arguments(
                      AVERAGE_PRECISION_NAME,
                      recall=recalls,
                      num_recalls=num_recalls,
                      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,
                  )
              )
  
              ap = COCOAveragePrecision(
                  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,
                  recalls=recalls,
                  num_recalls=num_recalls,
                  name=average_precision_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.extend(
                  ap.computations(
                      model_names=[model_name],
                      output_names=[output_name],
                  )
              )
              precisions_keys.append(computations[-1].keys[-1])
  
      def result(
          metrics: Dict[metric_types.MetricKey, Any]
      ) -> Dict[metric_types.MetricKey, Union[float, np.ndarray]]:
          precisions = [
              metrics[precisions_key]
              for precisions_key in precisions_keys
          ]
          value = np.nanmean(precisions)
          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 COCOMeanAveragePrecision obj's underlying member method code with example usage: obj._metric_computations(num_thresholds, iou_thresholds, class_ids, class_weights, max_num_detections, area_range, recalls, num_recalls, name, model_name, output_name, example_weighted, labels_to_stack, predictions_to_stack, num_detections_key, allow_missing_key) and returns: computations, dict