code: def configure_router(router: APIRouter, cfg: TaskConfig):
      base_metrics_endpoint = f"/{cfg.task.value}/{{name}}/metrics"
      new_base_metrics_endpoint = f"/{{name}}/{cfg.task.value}/metrics"
  
      @deprecate_endpoint(
          path=base_metrics_endpoint,
          new_path=new_base_metrics_endpoint,
          router_method=router.get,
          operation_id="get_dataset_metrics",
          name="get_dataset_metrics",
      )
      async def get_dataset_metrics(
          name: str,
          request_deps: CommonTaskHandlerDependencies = Depends(),
          current_user: User = Security(auth.get_current_user),
          datasets: DatasetsService = Depends(
              DatasetsService.get_instance
          ),
      ) -> List[MetricInfo]:
          dataset = await datasets.find_by_name(
              user=current_user,
              name=name,
              task=cfg.task,
              workspace=request_deps.workspace,
          )
  
          metrics = TasksFactory.get_task_metrics(dataset.task)
          metrics = metrics.metrics if metrics else []
  
          return [MetricInfo.parse_obj(metric) for metric in metrics]
  
      @deprecate_endpoint(
          path=base_metrics_endpoint + "/{metric}:summary",
          new_path=new_base_metrics_endpoint + "/{metric}:summary",
          router_method=router.post,
          operation_id="metric_summary",
          name="metric_summary",
      )
      async def metric_summary(
          name: str,
          metric: str,
          query: cfg.query,
          metric_params: MetricSummaryParams = Depends(),
          request_deps: CommonTaskHandlerDependencies = Depends(),
          current_user: User = Security(
              auth.get_current_user, scopes=[]
          ),
          datasets: DatasetsService = Depends(
              DatasetsService.get_instance
          ),
          metrics: MetricsService = Depends(
              MetricsService.get_instance
          ),
      ):
          dataset = await datasets.find_by_name(
              user=current_user,
              name=name,
              task=cfg.task,
              workspace=request_deps.workspace,
          )
  
          metric_ = TasksFactory.find_task_metric(
              task=cfg.task, metric_id=metric
          )
          record_class = TasksFactory.get_task_record(cfg.task)
  
          return metrics.summarize_metric(
              dataset=dataset,
              metric=metric_,
              record_class=record_class,
              query=query,
              **metric_params.parameters,
          )
  
file_path: argilla/src/argilla/server/apis/v0/handlers/metrics.py
imports: from dataclasses import dataclass
  from typing import Any, Dict, List, Optional
  from fastapi import APIRouter, Depends, Query, Request, Security
  from argilla.server.apis.v0.helpers import deprecate_endpoint
  from argilla.server.apis.v0.models.commons.params import CommonTaskHandlerDependencies
  from argilla.server.commons.config import TaskConfig, TasksFactory
  from argilla.server.models import User
  from argilla.server.pydantic_v1 import BaseModel, Field
  from argilla.server.security import auth
  from argilla.server.services.datasets import DatasetsService
  from argilla.server.services.metrics import MetricsService
label_desc: Use image node_id 1 for calling a global function with example usage: configure_router(router, cfg) and returns: unknown, metrics