class_docstr: Dataset for CLEVR. CLEVR is a reasoning task where given an image with some
  3D shapes you have to answer basic questions.
  
  Args:
      dataset_type (str): type of dataset, train|val|test
      config (DictConfig): Configuration Node representing all of the data necessary
                           to initialize CLEVR dataset class
      data_folder: Root folder in which all of the data will be present if passed
                   replaces default based on data_dir and data_folder in config.
class_docstr_tok: ["Dataset","for","CLEVR",".","CLEVR","is","a","reasoning","task","where","given","an","image","with","some","3D","shapes","you","have","to","answer","basic","questions",".","Args",":","dataset_type","(","str",")",":","type","of","dataset",",","train|val|test","config","(","DictConfig",")",":","Configuration","Node","representing","all","of","the","data","necessary","to","initialize","CLEVR","dataset","class","data_folder",":","Root","folder","in","which","all","of","the","data","will","be","present","if","passed","replaces","default","based","on","data_dir","and","data_folder","in","config","."]
code: def _build_vocab(self, questions, attribute):
      # Vocab should only be built from "train" as val and test are not observed in training
      if self._dataset_type != _CONSTANTS["train_dataset_key"]:
          return
  
      vocab_file = self._get_vocab_path(attribute)
  
      # Already exists, no need to recreate
      if os.path.exists(vocab_file):
          return
  
      # Create necessary dirs if not present
      os.makedirs(os.path.dirname(vocab_file), exist_ok=True)
  
      sentences = [question[attribute] for question in questions]
      build_attributes = self.config.build_attributes
  
      # Regex is default one in tokenize i.e. space
      kwargs = {
          "min_count": build_attributes.get("min_count", 1),
          "keep": build_attributes.get("keep", [";", ","]),
          "remove": build_attributes.get("remove", ["?", "."]),
      }
  
      if attribute == _CONSTANTS["answer_key"]:
          kwargs["only_unk_extra"] = False
  
      vocab = VocabFromText(sentences, **kwargs)
  
      with open(vocab_file, "w") as f:
          f.write("\n".join(vocab.word_list))
  
file_path: mmf/mmf/datasets/builders/clevr/dataset.py
imports: import json
  import os
  import numpy
  import torch
  from mmf.common.sample import Sample
  from mmf.datasets.base_dataset import BaseDataset
  from mmf.utils.distributed import is_main, synchronize
  from mmf.utils.general import get_mmf_root
  from mmf.utils.text import tokenize, VocabFromText
  from PIL import Image
label_desc: Use image node_id 5 for calling the CLEVRDataset obj's underlying member method code with example usage: obj._build_vocab(questions, attribute) without return types