code: def create_vocabs(filename, max_num_forms=100000):
      """Loads corpus and create vocabulary lists.
  
      Args:
        filename: file name of a corpus.
        max_num_forms: maximum number of tokens included.
  
      Returns:
        Dictionary containing named vocab dictionaries.
  
      """
      form_counter = collections.Counter()
      xpos_counter = collections.Counter()
      with tf.io.gfile.GFile(filename, "rb") as f:
          for line in codecs.getreader("utf-8")(f):
              line = line.strip()
              split = line.split("\t")
              if not line.startswith("#") and split[0]:
                  form_counter[split[CoNLLAttributes.FORM.value]] += 1
                  xpos_counter[split[CoNLLAttributes.XPOS.value]] += 1
  
      special_tokens = {PAD: PAD_ID, UNKNOWN: UNKNOWN_ID, ROOT: ROOT_ID}
  
      # create word form vocab
      vocabs = {"forms": {}, "xpos": {}}
      vocabs["forms"].update(special_tokens)
      vocabs["forms"].update(
          {
              form[0]: id
              for id, form in enumerate(
                  form_counter.most_common(max_num_forms),
                  start=ROOT_ID + 1,
              )
          }
      )
  
      # create xpos vocab
      vocabs["xpos"].update(special_tokens)
      vocabs["xpos"].update(
          {
              tag[0]: id
              for id, tag in enumerate(
                  xpos_counter.most_common(), start=ROOT_ID + 1
              )
          }
      )
  
      return vocabs
  
file_path: flax/examples/nlp_seq/input_pipeline.py
imports: import codecs
  import collections
  import enum
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: create_vocabs(filename, max_num_forms) and returns: vocabs