class_docstr: Computes best precision where recall is >= specified value.
  
  The threshold for the given recall value is computed and used to evaluate the
  corresponding precision.
  
  If `sample_weight` is `None`, weights default to 1.
  Use `sample_weight` of 0 to mask values.
docstr: Initializes PrecisionAtRecall metric.
  
  The metric supports using multiple outputs to form the labels/predictions if
  the user specifies the label/predcition keys to stack. In this case, the
  metric is not expected to work with multi-outputs. The metric only supports
  multi outputs if the output of model is already pre-stacked in the expected
  format, i.e. ['xmin', 'ymin', 'xmax', 'ymax', 'class_id'] for labels and
  ['xmin', 'ymin', 'xmax', 'ymax', 'class_id', 'confidence scores'] for
  predictions.
  
  Args:
    recall: A scalar or a list of scalar values in range `[0, 1]`.
    thresholds: (Optional) Thresholds to use for calculating the matrices. Use
      one of either thresholds or num_thresholds.
    num_thresholds: (Optional) Defaults to 1000. The number of thresholds to
      use for matching the given recall.
    name: (Optional) string name of the metric instance.
    iou_threshold: (Optional) Thresholds for a detection and ground truth pair
      with specific iou to be considered as a match. Default to 0.5
    class_id: (Optional) The class id for calculating metrics.
    class_weight: (Optional) The weight associated with the object class id.
    area_range: (Optional) A tuple (inclusive) representing the area-range for
      objects to be considered for metrics. Default to (0, inf).
    max_num_detections: (Optional) The maximum number of detections for a
      single image. Default to None.
    labels_to_stack: (Optional) Keys for columns to be stacked as a single
      numpy array as the labels. It is searched under the key labels, features
      and transformed features. The desired format is [left bounadary, top
      boudnary, right boundary, bottom boundary, class id]. e.g. ['xmin',
      'ymin', 'xmax', 'ymax', 'class_id']
    predictions_to_stack: (Optional) Output names for columns to be stacked as
      a single numpy array as the prediction. It should be the model's output
      names. The desired format is [left bounadary, top boudnary, right
      boundary, bottom boundary, class id, confidence score]. e.g. ['xmin',
      'ymin', 'xmax', 'ymax', 'class_id', 'scores']
    num_detections_key: (Optional) An output name in which to find the number
      of detections to use for evaluation for a given example. It does nothing
      if predictions_to_stack is not set. The value for this output should be
      a scalar value or a single-value tensor. The stacked predicitions will
      be truncated with the specified number of detections.
    allow_missing_key: (Optional) If true, the preprocessor will return empty
      array instead of raising errors.
docstr_tok: ["Initializes","PrecisionAtRecall","metric",".","The","metric","supports","using","multiple","outputs","to","form","the","labels\/predictions","if","the","user","specifies","the","label\/predcition","keys","to","stack",".","In","this","case",",","the","metric","is","not","expected","to","work","with","multi-outputs",".","The","metric","only","supports","multi","outputs","if","the","output","of","model","is","already","pre-stacked","in","the","expected","format",",","i.e",".","[","'xmin","'",",","'ymin","'",",","'xmax","'",",","'ymax","'",",","'class_id","'","]","for","labels","and","[","'xmin","'",",","'ymin","'",",","'xmax","'",",","'ymax","'",",","'class_id","'",",","'confidence","scores","'","]","for","predictions",".","Args",":","recall",":","A","scalar","or","a","list","of","scalar","values","in","range","`","[","0",",","1","]","`",".","thresholds",":","(","Optional",")","Thresholds","to","use","for","calculating","the","matrices",".","Use","one","of","either","thresholds","or","num_thresholds",".","num_thresholds",":","(","Optional",")","Defaults","to","1000",".","The","number","of","thresholds","to","use","for","matching","the","given","recall",".","name",":","(","Optional",")","string","name","of","the","metric","instance",".","iou_threshold",":","(","Optional",")","Thresholds","for","a","detection","and","ground","truth","pair","with","specific","iou","to","be","considered","as","a","match",".","Default","to","0.5","class_id",":","(","Optional",")","The","class","id","for","calculating","metrics",".","class_weight",":","(","Optional",")","The","weight","associated","with","the","object","class","id",".","area_range",":","(","Optional",")","A","tuple","(","inclusive",")","representing","the","area-range","for","objects","to","be","considered","for","metrics",".","Default","to","(","0",",","inf",")",".","max_num_detections",":","(","Optional",")","The","maximum","number","of","detections","for","a","single","image",".","Default","to","None",".","labels_to_stack",":","(","Optional",")","Keys","for","columns","to","be","stacked","as","a","single","numpy","array","as","the","labels",".","It","is","searched","under","the","key","labels",",","features","and","transformed","features",".","The","desired","format","is","[","left","bounadary",",","top","boudnary",",","right","boundary",",","bottom","boundary",",","class","id","]",".","e.g",".","[","'xmin","'",",","'ymin","'",",","'xmax","'",",","'ymax","'",",","'class_id","'","]","predictions_to_stack",":","(","Optional",")","Output","names","for","columns","to","be","stacked","as","a","single","numpy","array","as","the","prediction",".","It","should","be","the","model","'s","output","names",".","The","desired","format","is","[","left","bounadary",",","top","boudnary",",","right","boundary",",","bottom","boundary",",","class","id",",","confidence","score","]",".","e.g",".","[","'xmin","'",",","'ymin","'",",","'xmax","'",",","'ymax","'",",","'class_id","'",",","'scores","'","]","num_detections_key",":","(","Optional",")","An","output","name","in","which","to","find","the","number","of","detections","to","use","for","evaluation","for","a","given","example",".","It","does","nothing","if","predictions_to_stack","is","not","set",".","The","value","for","this","output","should","be","a","scalar","value","or","a","single-value","tensor",".","The","stacked","predicitions","will","be","truncated","with","the","specified","number","of","detections",".","allow_missing_key",":","(","Optional",")","If","true",",","the","preprocessor","will","return","empty","array","instead","of","raising","errors","."]
code: def __init__(
      self,
      recall: Union[float, List[float]],
      thresholds: Optional[List[float]] = None,
      num_thresholds: Optional[int] = None,
      name: Optional[str] = None,
      iou_threshold: Optional[float] = None,
      class_id: Optional[int] = None,
      class_weight: Optional[float] = None,
      area_range: Optional[Tuple[float, float]] = None,
      max_num_detections: Optional[int] = None,
      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,
  ):
      """Initializes PrecisionAtRecall metric.
  
      The metric supports using multiple outputs to form the labels/predictions if
      the user specifies the label/predcition keys to stack. In this case, the
      metric is not expected to work with multi-outputs. The metric only supports
      multi outputs if the output of model is already pre-stacked in the expected
      format, i.e. ['xmin', 'ymin', 'xmax', 'ymax', 'class_id'] for labels and
      ['xmin', 'ymin', 'xmax', 'ymax', 'class_id', 'confidence scores'] for
      predictions.
  
      Args:
        recall: A scalar or a list of scalar values in range `[0, 1]`.
        thresholds: (Optional) Thresholds to use for calculating the matrices. Use
          one of either thresholds or num_thresholds.
        num_thresholds: (Optional) Defaults to 1000. The number of thresholds to
          use for matching the given recall.
        name: (Optional) string name of the metric instance.
        iou_threshold: (Optional) Thresholds for a detection and ground truth pair
          with specific iou to be considered as a match. Default to 0.5
        class_id: (Optional) The class id for calculating metrics.
        class_weight: (Optional) The weight associated with the object class id.
        area_range: (Optional) A tuple (inclusive) representing the area-range for
          objects to be considered for metrics. Default to (0, inf).
        max_num_detections: (Optional) The maximum number of detections for a
          single image. Default to None.
        labels_to_stack: (Optional) Keys for columns to be stacked as a single
          numpy array as the labels. It is searched under the key labels, features
          and transformed features. The desired format is [left bounadary, top
          boudnary, right boundary, bottom boundary, class id]. e.g. ['xmin',
          'ymin', 'xmax', 'ymax', 'class_id']
        predictions_to_stack: (Optional) Output names for columns to be stacked as
          a single numpy array as the prediction. It should be the model's output
          names. The desired format is [left bounadary, top boudnary, right
          boundary, bottom boundary, class id, confidence score]. e.g. ['xmin',
          'ymin', 'xmax', 'ymax', 'class_id', 'scores']
        num_detections_key: (Optional) An output name in which to find the number
          of detections to use for evaluation for a given example. It does nothing
          if predictions_to_stack is not set. The value for this output should be
          a scalar value or a single-value tensor. The stacked predicitions will
          be truncated with the specified number of detections.
        allow_missing_key: (Optional) If true, the preprocessor will return empty
          array instead of raising errors.
      """
      for r in [recall] if isinstance(recall, float) else recall:
          if r < 0 or r > 1:
              raise ValueError(
                  "Argument `recall` must be in the range [0, 1]. "
                  f"Received: recall={r}"
              )
  
      super().__init__(
          thresholds=thresholds,
          num_thresholds=num_thresholds,
          recall=recall,
          name=name,
          class_id=class_id,
          iou_threshold=iou_threshold,
          area_range=area_range,
          max_num_detections=max_num_detections,
          class_weight=class_weight,
          labels_to_stack=labels_to_stack,
          predictions_to_stack=predictions_to_stack,
          num_detections_key=num_detections_key,
          allow_missing_key=allow_missing_key,
      )
  
imports: from typing import List, Optional, Tuple, Union
  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 preprocessors
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 1 to create a new ObjectDetectionPrecisionAtRecall object from inherited base classes: confusion_matrix_metrics with example: obj = ObjectDetectionPrecisionAtRecall(recall, thresholds, num_thresholds, name, iou_threshold, class_id, class_weight, area_range, max_num_detections, labels_to_stack, predictions_to_stack, num_detections_key, allow_missing_key)