code: def f1(name: str, query: Optional[str] = None) -> MetricSummary:
      """Computes F1 metrics for a dataset based on entity-level.
  
      Args:
          name: The dataset name.
          query: An ElasticSearch query with the
              `query string syntax <https://docs.argilla.io/en/latest/practical_guides/filter_dataset.html>`_
  
      Returns:
          The F1 metric summary containing precision, recall and the F1 score (averaged and per label).
  
      Examples:
          >>> from argilla.metrics.token_classification import f1
          >>> summary = f1(name="example-dataset")
          >>> summary.visualize() # will plot three bar charts with the results
          >>> summary.data # returns the raw result data
  
          To display the results as a table:
  
          >>> import pandas as pd
          >>> pd.DataFrame(summary.data.values(), index=summary.data.keys())
      """
      metric = singleton.active_api().compute_metric(
          name, metric="F1", query=query
      )
  
      return MetricSummary.new_summary(
          data=metric.results,
          visualization=lambda: helpers.f1(
              metric.results, metric.description
          ),
      )
  
imports: import warnings
  from enum import Enum
  from typing import Optional, Set, Union
  import deprecated
  from argilla.client import singleton
  from argilla.metrics import helpers
  from argilla.metrics.models import MetricSummary
label_desc: Use image node_id 12 for calling a global function with example usage: f1(name, query) and returns: MetricSummary