class_docstr: The dataset metrics service singleton
class_docstr_tok: ["The","dataset","metrics","service","singleton"]
docstr: Applies a metric summarization.
  
  Parameters
  ----------
  dataset:
      The records dataset
  metric:
      The selected metric
  record_class:
      The record class type for python metrics computation
  query:
      An optional query passed for records filtering
  metric_params:
      Related metrics parameters
  
  Returns
  -------
      The metric summarization info
docstr_tok: ["Applies","a","metric","summarization",".","Parameters","--","--","--","--","--","dataset",":","The","records","dataset","metric",":","The","selected","metric","record_class",":","The","record","class","type","for","python","metrics","computation","query",":","An","optional","query","passed","for","records","filtering","metric_params",":","Related","metrics","parameters","Returns","--","--","--","-","The","metric","summarization","info"]
code: def summarize_metric(
      self,
      dataset: ServiceDataset,
      metric: ServiceMetric,
      record_class: Optional[Type[ServiceRecord]] = None,
      query: Optional[ServiceRecordsQuery] = None,
      **metric_params,
  ) -> Dict[str, Any]:
      """
      Applies a metric summarization.
  
      Parameters
      ----------
      dataset:
          The records dataset
      metric:
          The selected metric
      record_class:
          The record class type for python metrics computation
      query:
          An optional query passed for records filtering
      metric_params:
          Related metrics parameters
  
      Returns
      -------
          The metric summarization info
      """
  
      if isinstance(metric, ServicePythonMetric):
          query = query or ServiceBaseRecordsQuery()
          query = metric.prepare_query(query)
          records = self.__dao__.scan_dataset(
              dataset,
              search=DaoRecordsSearch(
                  query=query,
                  sort=SortConfig(shuffle=metric.shuffle_records),
              ),
              limit=metric.records_to_fetch,
              exclude_fields={
                  "vectors",
                  "metrics",
                  "metadata",
              },  # Load records more efficiently
          )
          return metric.apply(map(record_class.parse_obj, records))
  
      return self.__dao__.compute_metric(
          metric_id=metric.id,
          metric_params=metric_params,
          dataset=dataset,
          query=query,
      )
  
file_path: argilla/src/argilla/server/services/metrics/service.py
imports: from typing import Any, Dict, Optional, Type
  from fastapi import Depends
  from argilla.server.daos.backend.search.model import SortConfig
  from argilla.server.daos.models.records import DaoRecordsSearch
  from argilla.server.daos.records import DatasetRecordsDAO
  from argilla.server.services.datasets import ServiceDataset
  from argilla.server.services.metrics.models import ServiceMetric, ServicePythonMetric
  from argilla.server.services.search.model import ServiceBaseRecordsQuery, ServiceRecordsQuery
  from argilla.server.services.tasks.commons import ServiceRecord
label_desc: Use image node_id 3 for calling the MetricsService obj's underlying member method code with example usage: obj.summarize_metric(dataset, metric, record_class, query) and returns: self, metric