code: def create_token_highlights(
      tokens: List[str],
      weights: List[float],
      c_map: Optional[Union[str, Callable]] = "viridis",
  ) -> str:
      """
      Generates an HTML string with tokens highlighted based on the corresponding weights using a color map.
  
      Args:
          tokens: List of tokens to highlight.
          weights: List of weights corresponding to each token.
          c_map: Optional color map to use for highlighting. Can be a string (name of a matplotlib colormap)
                      or a callable that returns an RGB tuple
  
      Returns:
          An HTML string with the tokens highlighted.
  
      Raises:
          ValueError: If the length of tokens and weights is not the same.
          ValueError: If tokens or weights are empty.
          TypeError: If c_map is not a string or a callable.
  
      Examples:
          >>> from argilla.client.feedback.utils import create_token_highlights
          >>> tokens = ["This", "is", "a", "test"]
          >>> weights = [0.1, 0.2, 0.3, 0.4]
          >>> html = create_token_highlights(tokens, weights)
          >>> html = create_token_highlights(tokens, weights, c_map='viridis')
          >>> html = create_token_highlights(tokens, weights, c_map=custom_RGB)
      """
      require_dependencies("matplotlib")
      import matplotlib.pyplot as plt
      from matplotlib.colors import rgb2hex
  
      if len(tokens) != len(weights):
          raise ValueError(
              "Length of tokens and weights must be the same."
          )
  
      if not tokens or not weights:
          raise ValueError("Token or weight lists must not be empty.")
  
      max_weight = max(weights)
      min_weight = min(weights)
      normalized_weights = [
          (w - min_weight) / (max_weight - min_weight)
          if max_weight != min_weight
          else 0
          for w in weights
      ]
  
      html_str = ["<p>"]
      for token, weight in zip(tokens, normalized_weights):
          if weight == 0:
              html_str.append(f"{token} ")
              continue
  
          rgba = None
  
          if callable(c_map):
              rgba = c_map(weight)
  
          elif isinstance(c_map, str):
              cmap = plt.get_cmap(c_map)
              rgba = cmap(weight)[:3]
  
          else:
              raise TypeError(
                  "c_map must be either a string or a function."
              )
  
          hex_color = rgb2hex(rgba)
          html_str.append(
              f'<span style="background-color: {hex_color}">{token}</span> '
          )
  
      html_str.append("</p>")
      return "".join(html_str)
  
file_path: argilla/src/argilla/client/feedback/utils/html_utils.py
imports: import base64
  import warnings
  from pathlib import Path
  from typing import Callable, List, Optional, Union
  from argilla.utils.dependency import require_dependencies
label_desc: Use image node_id 5 for calling a global function with example usage: create_token_highlights(tokens, weights, c_map) and returns: str