class_docstr: Build an EncodingVisualizer
  
  Args:
  
       tokenizer (:class:`~tokenizers.Tokenizer`):
          A tokenizer instance
  
       default_to_notebook (:obj:`bool`):
          Whether to render html output in a notebook by default
  
       annotation_converter (:obj:`Callable`, `optional`):
          An optional (lambda) function that takes an annotation in any format and returns
          an Annotation object
docstr: Generates a color palette for all the labels in a given set of annotations
  
  Args:
    annotations (:obj:`Annotation`):
      A list of annotations
  
  Returns:
      :obj:`dict`: A dictionary mapping labels to colors in HSL format
docstr_tok: ["Generates","a","color","palette","for","all","the","labels","in","a","given","set","of","annotations","Args",":","annotations","(",":","obj",":","`","Annotation","`",")",":","A","list","of","annotations","Returns",":",":","obj",":","`","dict","`",":","A","dictionary","mapping","labels","to","colors","in","HSL","format"]
code: def calculate_label_colors(
      annotations: AnnotationList,
  ) -> Dict[str, str]:
      """
      Generates a color palette for all the labels in a given set of annotations
  
      Args:
        annotations (:obj:`Annotation`):
          A list of annotations
  
      Returns:
          :obj:`dict`: A dictionary mapping labels to colors in HSL format
      """
      if len(annotations) == 0:
          return {}
      labels = set(map(lambda x: x.label, annotations))
      num_labels = len(labels)
      h_step = int(255 / num_labels)
      if h_step < 20:
          h_step = 20
      s = 32
      l = 64
      h = 10
      colors = {}
  
      for label in sorted(
          labels
      ):  # sort so we always get the same colors for a given set of labels
          colors[label] = f"hsl({h},{s}%,{l}%"
          h += h_step
      return colors
  
imports: import itertools
  import os
  import re
  from string import Template
  from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple
  from tokenizers import Encoding, Tokenizer
label_desc: Use image node_id 3 for calling the EncodingVisualizer obj's underlying member method code with example usage: obj.calculate_label_colors(annotations) and returns: colors, dict