code: def test_transformers_api_1(self):
      trn, val, preproc = txt.texts_from_array(
          x_train=self.trn[0],
          y_train=self.trn[1],
          x_test=self.val[0],
          y_test=self.val[1],
          class_names=self.classes,
          preprocess_mode="distilbert",
          maxlen=500,
          max_features=35000,
      )
      model = txt.text_classifier(
          "distilbert", train_data=trn, preproc=preproc
      )
      learner = ktrain.get_learner(
          model,
          train_data=trn,
          val_data=val,
          batch_size=6,
          eval_batch_size=EVAL_BS,
      )
  
      # test weight decay
      # NOTE due to transformers and/or AdamW bug, # val_accuracy is missing in training history if setting weight decay prior to training
      # self.assertEqual(learner.get_weight_decay(), None)
      # learner.set_weight_decay(1e-2)
      # self.assertAlmostEqual(learner.get_weight_decay(), 1e-2)
  
      # train
      lr = 5e-5
      hist = learner.fit_onecycle(lr, 1)
  
      # test training results
      self.assertAlmostEqual(max(hist.history["lr"]), lr)
      self.assertGreater(max(hist.history[VAL_ACC_NAME]), 0.9)
  
      # test top losses
      obs = learner.top_losses(n=1, val_data=None)
      self.assertIn(obs[0][0], list(range(len(val.x))))
      learner.view_top_losses(preproc=preproc, n=1, val_data=None)
  
      # test weight decay
      self.assertEqual(learner.get_weight_decay(), None)
      learner.set_weight_decay(1e-2)
      self.assertAlmostEqual(learner.get_weight_decay(), 1e-2)
  
      # test load and save model
      tmp_folder = ktrain.imports.tempfile.mkdtemp()
      learner.save_model(tmp_folder)
      learner.load_model(tmp_folder)
  
      # test validate
      cm = learner.validate()
      print(cm)
      for i, row in enumerate(cm):
          self.assertEqual(np.argmax(row), i)
  
      # test predictor
      p = ktrain.get_predictor(
          learner.model, preproc, batch_size=EVAL_BS
      )
      self.assertEqual(
          p.predict([TEST_DOC])[0], "soc.religion.christian"
      )
      tmp_folder = ktrain.imports.tempfile.mkdtemp()
      p.save(tmp_folder)
      p = ktrain.load_predictor(tmp_folder, batch_size=EVAL_BS)
      self.assertEqual(p.predict(TEST_DOC), "soc.religion.christian")
      self.assertEqual(np.argmax(p.predict_proba([TEST_DOC])[0]), 3)
      self.assertEqual(
          type(p.explain(TEST_DOC)), IPython.core.display.HTML
      )
  
file_path: ktrain/tests/test_transformers.py
imports: from unittest import TestCase, main, skip
  import IPython
  import numpy
  import testenv
  import ktrain
  from ktrain import text
  from ktrain.imports import ACC_NAME, VAL_ACC_NAME
label_desc: Use image node_id 2 for calling the TestTransformers obj's underlying member method code with example usage: obj.test_transformers_api_1() without return types