code: def twenty_news_transformers(
      n, num_labels=10, subset="train", device="cpu"
  ):
      train = fetch_20newsgroups(subset=subset)
      train_x = train.data[:n]
      train_y = np.random.randint(0, num_labels, size=n)
  
      tokenizer = AutoTokenizer.from_pretrained(
          "sshleifer/tiny-distilroberta-base"
      )
  
      data = []
      for i, doc in enumerate(train_x):
          encoded_dict = tokenizer.encode_plus(
              doc,
              add_special_tokens=True,
              max_length=20,
              padding=True,
              return_attention_mask=True,
              return_tensors="pt",
              truncation="longest_first",
          )
          encoded_dict = encoded_dict.to(device)
          data.append(
              (
                  encoded_dict["input_ids"],
                  encoded_dict["attention_mask"],
                  train_y[i],
              )
          )
  
      return TransformersDataset(data)
  
imports: import string
  import numpy
  from collections import Counter
  from scipy import sparse
  from sklearn.datasets import fetch_20newsgroups
  from small_text.data.datasets import SklearnDataset, TextDataset
  from small_text.data.sampling import _get_class_histogram
  from small_text.utils.labels import csr_to_list, list_to_csr
label_desc: Use image node_id 12 for calling a global function with example usage: twenty_news_transformers(n, num_labels, subset, device) and returns: TransformersDataset