code: def pr_curve(
      tag, labels, predictions, num_thresholds=127, weights=None
  ):
      # weird, value > 127 breaks protobuf
      num_thresholds = min(num_thresholds, 127)
      data = compute_curve(
          labels,
          predictions,
          num_thresholds=num_thresholds,
          weights=weights,
      )
      pr_curve_plugin_data = PrCurvePluginData(
          version=0, num_thresholds=num_thresholds
      ).SerializeToString()
      plugin_data = SummaryMetadata.PluginData(
          plugin_name="pr_curves", content=pr_curve_plugin_data
      )
      smd = SummaryMetadata(plugin_data=plugin_data)
      tensor = TensorProto(
          dtype="DT_FLOAT",
          float_val=data.reshape(-1).tolist(),
          tensor_shape=TensorShapeProto(
              dim=[
                  TensorShapeProto.Dim(size=data.shape[0]),
                  TensorShapeProto.Dim(size=data.shape[1]),
              ]
          ),
      )
      return Summary(
          value=[Summary.Value(tag=tag, metadata=smd, tensor=tensor)]
      )
  
imports: import json
  import logging
  import os
  import struct
  from typing import Any, List, Optional
  import torch
  import numpy
  from google.protobuf import struct_pb2
  from tensorboard.compat.proto.summary_pb2 import HistogramProto, Summary, SummaryMetadata
  from tensorboard.compat.proto.tensor_pb2 import TensorProto
  from tensorboard.compat.proto.tensor_shape_pb2 import TensorShapeProto
  from tensorboard.plugins.custom_scalar import layout_pb2
  from tensorboard.plugins.pr_curve.plugin_data_pb2 import PrCurvePluginData
  from tensorboard.plugins.text.plugin_data_pb2 import TextPluginData
  from ._convert_np import make_np
  from ._utils import _prepare_video, convert_to_HWC
label_desc: Use image node_id 24 for calling a global function with example usage: pr_curve(tag, labels, predictions, num_thresholds, weights) and returns: Summary