title: How do I use slicing as I pass a transformer dataset to Trainer?
body: <p>In reference to <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter3/section3.ipynb" rel="nofollow noreferrer">this colab notebook</a> (from Huggingface Transformer course <a href="https://huggingface.co/course/chapter3/3?fw=pt" rel="nofollow noreferrer">here</a>), if I run</p>
  <pre><code>tokenized_datasets[&quot;train&quot;][:8]
  </code></pre>
  <p>the <code>dtype</code> is a <code>dict</code> instead of a <code>Dataset</code> and the slicing would return some data.
  If I pass the slicing in here, I get a Key error, which I assume has to do with the fact I'm no longer passing a Dataset.</p>
  <pre><code>from transformers import Trainer
  
  trainer = Trainer(
      model,
      training_args,
      train_dataset=tokenized_datasets[&quot;train&quot;][:8],
      eval_dataset=tokenized_datasets[&quot;validation&quot;],
      #data_collator=data_collator,
      tokenizer=tokenizer,
  )
  
  
  
  trainer.train()
  ***** Running training *****
    Num examples = 7
    Num Epochs = 3
    Instantaneous batch size per device = 8
    Total train batch size (w. parallel, distributed &amp; accumulation) = 8
    Gradient Accumulation steps = 1
    Total optimization steps = 3
  ---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-20-3435b262f1ae&gt; in &lt;module&gt;()
  ----&gt; 1 trainer.train()
  </code></pre>
  <p>Is there a simple way to just pass a subset of the Dataset rows for training or validation?</p>