code: def main(num_iterations=10):
      # Active learning parameters
      num_classes = len(TWENTY_NEWS_SUBCATEGORIES)
      clf_factory = TransformerBasedClassificationFactory(
          TRANSFORMER_MODEL,
          num_classes,
          kwargs=dict({"device": "cuda"}),
      )
      query_strategy = RandomSampling()
  
      # Prepare some data
      train, test = get_twenty_newsgroups_corpus(
          categories=TWENTY_NEWS_SUBCATEGORIES
      )
  
      tokenizer = AutoTokenizer.from_pretrained(
          TRANSFORMER_MODEL.model, cache_dir=".cache/"
      )
      train = preprocess_data(tokenizer, train.data, train.target)
  
      test = preprocess_data(tokenizer, test.data, test.target)
  
      # Active learner
      active_learner = PoolBasedActiveLearner(
          clf_factory, query_strategy, train
      )
      indices_labeled = initialize_active_learner(
          active_learner, train.y
      )
  
      try:
          perform_active_learning(
              active_learner,
              train,
              indices_labeled,
              test,
              num_iterations,
          )
      except PoolExhaustedException:
          print("Error! Not enough samples left to handle the query.")
      except EmptyPoolException:
          print(
              "Error! No more samples left. (Unlabeled pool is empty)"
          )
  
file_path: small-text/examples/examplecode/transformers_multiclass_classification.py
imports: import numpy
  from transformers import AutoTokenizer
  from small_text import EmptyPoolException, PoolBasedActiveLearner, PoolExhaustedException, RandomSampling, TransformerBasedClassificationFactory, TransformerModelArguments, random_initialization_balanced
  from examplecode.data.corpus_twenty_news import get_twenty_newsgroups_corpus
  from examplecode.data.example_data_transformers import preprocess_data
  from examplecode.shared import evaluate
label_desc: Use image node_id 1 for calling a global function with example usage: main(num_iterations) without return types