code: def token_classification_mapper(inputs, outputs):
      if isinstance(inputs, str):
          text = inputs
      elif isinstance(inputs, dict):
          text = inputs.get("text", "")
      else:
          text = ""
      tokens = (
          outputs.get("tokens") if isinstance(outputs, dict) else None
      )
      return TokenClassificationRecord(
          text=text,
          tokens=tokens or _default_tokenization_pattern.split(text),
          prediction=[
              (entity["label"], entity["start"], entity["end"])
              for entity in (
                  outputs.get("entities")
                  if isinstance(outputs, dict)
                  else outputs
              )
          ],
          event_timestamp=datetime.datetime.now(),
      )
  
imports: import datetime
  import json
  import logging
  import re
  from typing import Any, Callable, Dict, List, Optional, Tuple
  from argilla.client.models import Record, TextClassificationRecord, TokenClassificationRecord
  from argilla.monitoring.base import BaseMonitor
  from argilla.utils.dependency import require_dependencies
  from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
  from starlette.requests import Request
  from starlette.responses import JSONResponse, Response, StreamingResponse
  from starlette.types import Message, Receive
label_desc: Use image node_id 1 for calling a global function with example usage: token_classification_mapper(inputs, outputs) and returns: TokenClassificationRecord