code: def test_tokens_to_indices_uses_pos_tags(self):
      tokens = self.tokenizer.split_words("This is a sentence.")
      tokens = [t for t in tokens] + [Token("</S>")]
      vocab = Vocabulary()
      verb_index = vocab.add_token_to_namespace(
          "VERB", namespace="pos_tags"
      )
      cop_index = vocab.add_token_to_namespace(
          "VBZ", namespace="pos_tags"
      )
      none_index = vocab.add_token_to_namespace(
          "NONE", namespace="pos_tags"
      )
      # Have to add other tokens too, since we're calling `tokens_to_indices` on all of them
      vocab.add_token_to_namespace("DET", namespace="pos_tags")
      vocab.add_token_to_namespace("NOUN", namespace="pos_tags")
      vocab.add_token_to_namespace("PUNCT", namespace="pos_tags")
  
      indexer = PosTagIndexer(coarse_tags=True)
  
      indices = indexer.tokens_to_indices(tokens, vocab, "tokens")
      assert len(indices) == 1
      assert "tokens" in indices
      assert indices["tokens"][1] == verb_index
      assert indices["tokens"][-1] == none_index
  
      indexer._coarse_tags = False  # pylint: disable=protected-access
      assert indexer.tokens_to_indices(
          [tokens[1]], vocab, "coarse"
      ) == {"coarse": [cop_index]}
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/data/token_indexers/pos_tag_indexer_test.py
imports: from __future__ import absolute_import
  from collections import defaultdict
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Token, Vocabulary
  from allennlp.data.token_indexers import PosTagIndexer
  from allennlp.data.tokenizers.word_splitter import SpacyWordSplitter
label_desc: Use image node_id 3 for calling the TestPosTagIndexer obj's underlying member method code with example usage: obj.test_tokens_to_indices_uses_pos_tags() without return types