class_docstr: Ranking metric.
class_docstr_tok: ["Ranking","metric","."]
docstr: Compute measure_name on the true and run relevance values provided.
  
  Return a dictionary mapping metric names to the computed values.
docstr_tok: ["Compute","measure_name","on","the","true","and","run","relevance","values","provided",".","Return","a","dictionary","mapping","metric","names","to","the","computed","values","."]
code: def compute_measure(
      self,
      true_relevances: Dict[str, int],
      run_relevances: Dict[str, int],
      evaluator_measure_name: str,
  ) -> float:
      """Compute measure_name on the true and run relevance values provided.
  
      Return a dictionary mapping metric names to the computed values.
      """
      # Parse the measure name
      parsed_measure_name, k = self.parse_measure_name(
          evaluator_measure_name
      )
  
      # If the measure is a binary measure, we binarize the true relevance values.
      if (
          parsed_measure_name in self.BINARY_MEASURES
          and self.multiple_relevance_values
      ):
          true_relevances = binarize_dict(true_relevances)
  
      # pytrec doesn't support parametrization for some measure names. For
      # such measures, we achieve parametrization by simply limiting
      # run_relevances dictionary to the top k relevance values.
      if parsed_measure_name in self.CUSTOM_PARAMETRIZED_MEASURES and k:
          evaluator_measure_name = parsed_measure_name  # Pass the non-parametrized name to pytrec
          run_relevances = self.limit_relevance_dict(run_relevances, k)
  
      # RelevanceEvaluator expects a dictionary that maps Query IDs to their
      # relevance dictionaries. To pass our relevance dictionaries in the
      # right format, we wrap them in a dictionary.
      measure_names, true_qrels, run_qrels = (
          {evaluator_measure_name},
          {"_": true_relevances},
          {"_": run_relevances},
      )
      evaluator = pytrec_eval.RelevanceEvaluator(
          true_qrels, measure_names
      )
      evaluations = evaluator.evaluate(run_qrels)
      score = list(evaluations["_"].values())[0]
      return score
  
imports: from dataclasses import dataclass
  from typing import Callable, Dict, List, Tuple, Optional
  import pytrec_eval
  from helm.benchmark.adaptation.adapters.adapter_factory import ADAPT_RANKING_BINARY
  from helm.benchmark.adaptation.request_state import RequestState
  from helm.benchmark.adaptation.adapter_spec import AdapterSpec
  from helm.benchmark.scenarios.scenario import unpack_tag, CORRECT_TAG, Reference
  from helm.common.request import RequestResult
  from helm.common.general import binarize_dict
  from .metric import Metric
  from .metric_name import MetricName
  from .metric_service import MetricService
  from .statistic import Stat
label_desc: Use image node_id 15 for calling the RankingMetric obj's underlying member method code with example usage: obj.compute_measure(true_relevances, run_relevances, evaluator_measure_name) and returns: score