code: def test_vocab_from_text(self):
      vocab = text_utils.VocabFromText(self.VOCAB_EXAMPLE_SENTENCES)
  
      self.assertEqual(vocab.get_size(), 41)
      self.assertEqual(len(vocab), 41)
      self.assertEqual(vocab.get_unk_index(), 1)
  
      self.assertEqual(vocab.itos[0], vocab.DEFAULT_TOKENS[0])
      self.assertEqual(vocab.itos[34], "that")
      self.assertEqual(vocab.itos[31], "cube")
      self.assertEqual(vocab.itos[25], "cyan")
      self.assertEqual(vocab.itos[20], "the")
      self.assertEqual(vocab.itos[10], "than")
  
      self.assertEqual(vocab.stoi["sphere"], 30)
      self.assertEqual(vocab.stoi["shape"], 22)
  
      vocab = text_utils.VocabFromText(
          self.VOCAB_EXAMPLE_SENTENCES, min_count=10
      )
      self.assertEqual(vocab.get_size(), 5)
      self.assertEqual(vocab.itos[vocab.get_size() - 1], "the")
  
      vocab = text_utils.VocabFromText(
          self.VOCAB_EXAMPLE_SENTENCES, min_count=11
      )
      self.assertEqual(vocab.get_size(), 4)
  
      vocab = text_utils.VocabFromText(
          self.VOCAB_EXAMPLE_SENTENCES,
          min_count=11,
          only_unk_extra=True,
      )
      self.assertEqual(vocab.get_size(), 1)
      self.assertEqual(vocab.itos[vocab.get_size() - 1], "<unk>")
  
      vocab = text_utils.VocabFromText(
          self.VOCAB_EXAMPLE_SENTENCES, min_count=1, remove=[";"]
      )
      self.assertEqual(vocab.get_size(), 40)
  
      vocab = text_utils.VocabFromText(
          self.VOCAB_EXAMPLE_SENTENCES,
          min_count=1,
          remove=[";", ",", "?"],
      )
      self.assertEqual(vocab.get_size(), 38)
  
      vocab = text_utils.VocabFromText(
          self.VOCAB_EXAMPLE_SENTENCES,
          min_count=1,
          keep=["?"],
          remove=";",
      )
      self.assertEqual(vocab.get_size(), 40)
  
imports: import os
  import unittest
  import mmf.utils.text
  import numpy
  import torch
  from mmf.common.registry import registry
  from mmf.common.sample import Sample, SampleList
  from mmf.utils.configuration import Configuration
  from mmf.utils.env import setup_imports
  from mmf.utils.general import get_mmf_root
  from tests.test_utils import dummy_args
  from tests.utils.test_model import TestDecoderModel
label_desc: Use image node_id 5 for calling the TestUtilsText obj's underlying member method code with example usage: obj.test_vocab_from_text() without return types