code: def test_token_tags():
      # example sentence
      sentence = Sentence("I love Berlin")
  
      # set 4 labels for 2 tokens ('love' is tagged twice)
      sentence[1].add_label("pos", "verb")
      sentence[1].add_label("sentiment", "positive")
      sentence[2].add_label("pos", "proper noun")
      sentence[0].add_label("pos", "pronoun")
  
      # check if there are three POS labels with correct text and values
      labels: List[Label] = sentence.get_labels("pos")
      assert len(labels) == 3
      assert labels[0].data_point.text == "I"
      assert labels[0].value == "pronoun"
      assert labels[1].data_point.text == "love"
      assert labels[1].value == "verb"
      assert labels[2].data_point.text == "Berlin"
      assert labels[2].value == "proper noun"
  
      # check if there are is one SENTIMENT label with correct text and values
      labels: List[Label] = sentence.get_labels("sentiment")
      assert len(labels) == 1
      assert labels[0].data_point.text == "love"
      assert labels[0].value == "positive"
  
      # check if all tokens are correctly labeled
      assert len(sentence) == 3
      assert sentence[0].text == "I"
      assert sentence[1].text == "love"
      assert sentence[2].text == "Berlin"
      assert len(sentence[0].get_labels("pos")) == 1
      assert len(sentence[1].get_labels("pos")) == 1
      assert len(sentence[1].labels) == 2
      assert len(sentence[2].get_labels("pos")) == 1
  
      assert sentence[1].get_label("pos").value == "verb"
      assert sentence[1].get_label("sentiment").value == "positive"
  
      # remove the pos label from the last word
      sentence[2].remove_labels("pos")
      # there should be 2 POS labels left
      labels: List[Label] = sentence.get_labels("pos")
      assert len(labels) == 2
      assert len(sentence[0].get_labels("pos")) == 1
      assert len(sentence[1].get_labels("pos")) == 1
      assert len(sentence[1].labels) == 2
      assert len(sentence[2].get_labels("pos")) == 0
  
      # now remove all pos tags
      sentence.remove_labels("pos")
      print(sentence[0].get_labels("pos"))
      assert len(sentence.get_labels("pos")) == 0
      assert len(sentence.get_labels("sentiment")) == 1
      assert len(sentence.labels) == 1
  
      assert len(sentence[0].get_labels("pos")) == 0
      assert len(sentence[1].get_labels("pos")) == 0
      assert len(sentence[2].get_labels("pos")) == 0
  
file_path: flair/tests/test_labels.py
imports: from typing import List
  from flair.data import Label, Relation, Sentence, Span
label_desc: Use image node_id 1 for calling a global function with example usage: test_token_tags() without return types