code: def monitor(
      task_model: Union[Language, Pipeline, SequenceTagger],
      dataset: str,
      sample_rate: float = 0.3,
      agent: Optional[str] = None,
      log_interval: float = 5,
  ) -> Union[BaseMonitor, Language, Pipeline, SequenceTagger]:
      """Automatically monitor (i.e. log) data fed through Transformer pipelines,
      spaCy models or flAIr taggers.
  
      Args:
          task_model (Union[Language, Pipeline, SequenceTagger]): The spaCy `Language`,
              transformers `Pipeline` or flAIr `SequenceTagger`.
          dataset (str): The Argilla dataset to log data into.
          sample_rate (float, optional): The portion of processed data to log. Defaults to 0.3.
          agent (Optional[str], optional): The name of the logging agent. Defaults to None.
          log_interval (float, optional): The interval for uploading in seconds. Defaults to 5.
  
      Returns:
          Union[BaseMonitor, Language, Pipeline, SequenceTagger]: The monitor that acts equivalently
              to the input task_model.
      """
      model_monitor = None
      api = active_api()
      if isinstance(task_model, Language):
          model_monitor = ner_monitor(
              task_model,
              api=api,
              dataset=dataset,
              sample_rate=sample_rate,
              log_interval=log_interval,
          )
      elif isinstance(task_model, Pipeline):
          model_monitor = huggingface_monitor(
              task_model,
              api=api,
              dataset=dataset,
              sample_rate=sample_rate,
              log_interval=log_interval,
          )
      elif isinstance(task_model, SequenceTagger):
          model_monitor = flair_monitor(
              task_model,
              api=api,
              dataset=dataset,
              sample_rate=sample_rate,
              log_interval=log_interval,
          )
      if model_monitor:
          model_monitor.agent = agent
          return model_monitor
  
      warnings.warn(
          "The provided task model is not supported by monitoring module. Predictions won't be logged into argilla."
      )
      return task_model
  
file_path: argilla/src/argilla/monitoring/model_monitor.py
imports: import logging
  import warnings
  from typing import Optional, Union
  from ..client.singleton import active_api
  from ._flair import SequenceTagger, flair_monitor
  from ._spacy import Language, ner_monitor
  from ._transformers import Pipeline, huggingface_monitor
  from .base import BaseMonitor
label_desc: Use image node_id 1 for calling a global function with example usage: monitor(task_model, dataset, sample_rate, agent, log_interval) and returns: task_model, model_monitor