class_docstr: A class for decoding labels using the idea of siamese networks / bi-encoders. This can be used for all classification tasks in flair.
  
  Args:
      label_encoder (flair.embeddings.TokenEmbeddings):
          The label encoder used to encode the labels into an embedding.
      label_dictionary (flair.data.Dictionary):
          The label dictionary containing the mapping between labels and indices.
  
  Attributes:
      label_encoder (flair.embeddings.TokenEmbeddings):
          The label encoder used to encode the labels into an embedding.
      label_dictionary (flair.data.Dictionary):
          The label dictionary containing the mapping between labels and indices.
  
  Methods:
      forward(self, label_embeddings: torch.Tensor, context_embeddings: torch.Tensor) -> torch.Tensor:
          Takes the label embeddings and context embeddings as input and returns a tensor of label scores.
  
  Examples:
      label_dictionary = corpus.make_label_dictionary("ner")
      label_encoder = TransformerWordEmbeddings('bert-base-ucnased')
      label_verbalizer_decoder = LabelVerbalizerDecoder(label_encoder, label_dictionary)
class_docstr_tok: ["A","class","for","decoding","labels","using","the","idea","of","siamese","networks","\/","bi-encoders",".","This","can","be","used","for","all","classification","tasks","in","flair",".","Args",":","label_encoder","(","flair.embeddings.TokenEmbeddings",")",":","The","label","encoder","used","to","encode","the","labels","into","an","embedding",".","label_dictionary","(","flair.data.Dictionary",")",":","The","label","dictionary","containing","the","mapping","between","labels","and","indices",".","Attributes",":","label_encoder","(","flair.embeddings.TokenEmbeddings",")",":","The","label","encoder","used","to","encode","the","labels","into","an","embedding",".","label_dictionary","(","flair.data.Dictionary",")",":","The","label","dictionary","containing","the","mapping","between","labels","and","indices",".","Methods",":","forward","(","self",",","label_embeddings",":","torch.Tensor",",","context_embeddings",":","torch.Tensor",")","-",">","torch.Tensor",":","Takes","the","label","embeddings","and","context","embeddings","as","input","and","returns","a","tensor","of","label","scores",".","Examples",":","label_dictionary","=","corpus.make_label_dictionary","(","``","ner","''",")","label_encoder","=","TransformerWordEmbeddings","(","'bert-base-ucnased","'",")","label_verbalizer_decoder","=","LabelVerbalizerDecoder","(","label_encoder",",","label_dictionary",")"]
docstr: Takes a label dictionary and returns a list of sentences with verbalized labels.
  
  Args:
      label_dictionary (flair.data.Dictionary): The label dictionary to verbalize.
  
  Returns:
      A list of sentences with verbalized labels.
  
  Examples:
      label_dictionary = corpus.make_label_dictionary("ner")
      verbalized_labels = LabelVerbalizerDecoder.verbalize_labels(label_dictionary)
      print(verbalized_labels)
      [Sentence: "begin person", Sentence: "inside person", Sentence: "end person", Sentence: "single org", ...]
docstr_tok: ["Takes","a","label","dictionary","and","returns","a","list","of","sentences","with","verbalized","labels",".","Args",":","label_dictionary","(","flair.data.Dictionary",")",":","The","label","dictionary","to","verbalize",".","Returns",":","A","list","of","sentences","with","verbalized","labels",".","Examples",":","label_dictionary","=","corpus.make_label_dictionary","(","``","ner","''",")","verbalized_labels","=","LabelVerbalizerDecoder.verbalize_labels","(","label_dictionary",")","print","(","verbalized_labels",")","[","Sentence",":","``","begin","person","''",",","Sentence",":","``","inside","person","''",",","Sentence",":","``","end","person","''",",","Sentence",":","``","single","org","''",",","...","]"]
code: def verbalize_labels(label_dictionary: Dictionary) -> List[Sentence]:
      """Takes a label dictionary and returns a list of sentences with verbalized labels.
  
      Args:
          label_dictionary (flair.data.Dictionary): The label dictionary to verbalize.
  
      Returns:
          A list of sentences with verbalized labels.
  
      Examples:
          label_dictionary = corpus.make_label_dictionary("ner")
          verbalized_labels = LabelVerbalizerDecoder.verbalize_labels(label_dictionary)
          print(verbalized_labels)
          [Sentence: "begin person", Sentence: "inside person", Sentence: "end person", Sentence: "single org", ...]
      """
      verbalized_labels = []
      for byte_label, idx in label_dictionary.item2idx.items():
          str_label = byte_label.decode("utf-8")
          if label_dictionary.span_labels:
              # verbalize BIOES labels
              if str_label == "O":
                  verbalized_labels.append("outside")
              elif str_label.startswith("B-"):
                  verbalized_labels.append(
                      "begin " + str_label.split("-")[1]
                  )
              elif str_label.startswith("I-"):
                  verbalized_labels.append(
                      "inside " + str_label.split("-")[1]
                  )
              elif str_label.startswith("E-"):
                  verbalized_labels.append(
                      "ending " + str_label.split("-")[1]
                  )
              elif str_label.startswith("S-"):
                  verbalized_labels.append(
                      "single " + str_label.split("-")[1]
                  )
              # if label is not BIOES, use label itself
              else:
                  verbalized_labels.append(str_label)
          else:
              verbalized_labels.append(str_label)
      return list(map(Sentence, verbalized_labels))
  
file_path: flair/flair/nn/decoder.py
imports: import logging
  from typing import List, Optional
  import torch
  import flair
  from flair.data import Dictionary, Sentence
  from flair.embeddings import Embeddings
  from flair.nn.distance import CosineDistance, EuclideanDistance, HyperbolicDistance, LogitCosineDistance, NegativeScaledDotProduct
  from flair.training_utils import store_embeddings
label_desc: Use image node_id 2 for calling the LabelVerbalizerDecoder obj's underlying member method code with example usage: obj.verbalize_labels(label_dictionary) and returns: list