title: Unable to create custom dataset and dataloader using torchtext
body: <p>I have questions regarding building custom dataset and iterator using <code>torchtext</code>. I used the following code found in this <a href="http://mlexplained.com/2018/02/08/a-comprehensive-tutorial-to-torchtext/" rel="nofollow noreferrer">post</a> and modified based on my case:</p>
  <pre class="lang-py prettyprint-override"><code>tokenizer = XLNetTokenizer.from_pretrained(&quot;xlnet-base-cased&quot;)
  text_field = Field(sequential=True, eos_token=&quot;[CLS]&quot;, tokenize=tokenizer)
  label_field = Field(sequential=False, use_vocab=False)
  data_fields = [(&quot;file&quot;, None),
                 (&quot;text&quot;, text_field),
                 (&quot;label&quot;, label_field)]
  train, val = train_test_split(input_dt, test_size=0.1)
  train.to_csv(&quot;train_output_path&quot;, index=False)
  val.to_csv(&quot;val_output_path&quot;, index=False)
  train, val = TabularDataset(path=&quot;path&quot;, train=&quot;train.csv&quot;, validation=&quot;val.csv&quot;,
                              format=&quot;csv&quot;, skip_header=True, fields=data_fields)
  </code></pre>
  <p>When it comes to <code>text_field.build_vocab(train)</code>, I got this error: <code>TypeError: '&lt;' not supported between instances of 'list' and 'int'</code>.</p>
  <p>The only difference between my code and the post is the pre-trained word embeddings. In the post, the author used glove, which I use <code>XLNetTokenizer</code> from <code>transformers</code> package. I also searched for other posts who used the similar method, but they all used the pre-trained word embeddings, therefore they did have such an issue.</p>
  <p>Does anyone know how to fix this issue? Many thanks!</p>