code: def entity_density(
      name: str,
      query: Optional[str] = None,
      compute_for: Union[str, ComputeFor] = Predictions,
      interval: float = 0.005,
  ) -> MetricSummary:
      """Computes the entity density distribution. Then entity density is calculated at
      record level for each mention as ``mention_length/tokens_length``
  
      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>`_
          compute_for: Metric can be computed for annotations or predictions. Accepted values are
              ``Annotations`` and ``Predictions``. Default to ``Predictions``.
          interval: The interval for histogram. The entity density is defined in the range 0-1.
  
      Returns:
          The summary entity density distribution
  
      Examples:
          >>> from argilla.metrics.token_classification import entity_density
          >>> summary = entity_density(name="example-dataset")
          >>> summary.visualize()
      """
  
      warnings.warn(
          message=_UNUSED_METRIC_WARNING_MESSAGE,
          category=DeprecationWarning,
      )
  
      metric = singleton.active_api().compute_metric(
          name,
          metric=f"{_check_compute_for(compute_for)}_entity_density",
          query=query,
          interval=interval,
      )
  
      return MetricSummary.new_summary(
          data=metric.results,
          visualization=lambda: helpers.histogram(
              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 8 for calling a global function with example usage: entity_density(name, query, compute_for, interval) and returns: MetricSummary