code: def token_frequency(
      name: str, query: Optional[str] = None, tokens: int = 1000
  ) -> MetricSummary:
      """Computes the token frequency distribution for a number of tokens.
  
      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>`_
          tokens: The top-k number of tokens to retrieve
  
      Returns:
          The summary for token frequency distribution
  
      Examples:
          >>> from argilla.metrics.token_classification import token_frequency
          >>> summary = token_frequency(name="example-dataset", token=50)
          >>> summary.visualize() # will plot a histogram with results
          >>> summary.data # the top-50 tokens frequency
      """
      metric = singleton.active_api().compute_metric(
          name, metric="token_frequency", query=query, size=tokens
      )
  
      return MetricSummary.new_summary(
          data=metric.results,
          visualization=lambda: helpers.bar(
              metric.results,
              title=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 2 for calling a global function with example usage: token_frequency(name, query, tokens) and returns: MetricSummary