code: def evaluate_model(model, tokenizer, dataset, device, batch_size):
      p = pipeline(
          "sentiment-analysis",
          model,
          tokenizer=tokenizer,
          device=device,
      )
      results = p(
          KeyDataset(dataset, "sentence"), batch_size=batch_size
      )
      start = time.time()
      pred_labels = [
          0 if result["label"] == "NEGATIVE" else 1
          for result in results
      ]
      end = time.time()
      accuracy = np.sum(np.equal(pred_labels, dataset["label"])) / len(
          pred_labels
      )
      print(
          f"{len(pred_labels)} sentences evaluated in {end - start:.2f} s. accuracy = {accuracy}"
      )
  
file_path: quanto/examples/nlp/text-classification/sst2/quantize_sst2_model.py
imports: import argparse
  import io
  import time
  import numpy
  import torch
  from datasets import load_dataset
  from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
  from transformers.pipelines.pt_utils import KeyDataset
  from quanto import Calibration, freeze, quantize
label_desc: Use image node_id 1 for calling a global function with example usage: evaluate_model(model, tokenizer, dataset, device, batch_size) without return types