code: def prepare_dataset(
      examples: List[Dict[str, torch.LongTensor]],
      batch_size: int = 1,
      pad_token_id: Optional[int] = None,
  ):
      """
      Prepare the dataset by making sure that we have the right format and `batch_size`
      Args:
          examples (`List[Dict[str, torch.LongTensor]]`):
              List of data to prepare
          batch_size (`int`, defaults to `1`):
              Batch size of the data
          pad_token_id (`Optional[int]`, defaults to `None`):
              Pad token id of the model
      Returns:
          ` List[Dict[str, torch.LongTensor]]`: Batched dataset
      """
      new_examples = []
      for example in examples:
          input_ids = example["input_ids"]
          attention_mask = example["attention_mask"]
          new_examples.append(
              {
                  "input_ids": torch.LongTensor(input_ids),
                  "attention_mask": torch.LongTensor(attention_mask),
              }
          )
      if batch_size > 1 and pad_token_id is None:
          raise ValueError(
              "You need to pass a `pad_token_id` in `quantize_model` if you want to have examples with batch size > 1"
          )
      new_examples = [
          collate_data(
              new_examples[start : start + batch_size],
              contain_labels=False,
              pad_token_id=pad_token_id,
          )
          for start in range(0, len(new_examples), batch_size)
      ]
      return new_examples
  
file_path: optimum/optimum/gptq/data.py
imports: import random
  from typing import Any, Dict, List, Optional
  import numpy
  import torch
  from datasets import load_dataset
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_dataset(examples, batch_size, pad_token_id) and returns: new_examples