code: def test_training_summarizer_bert(self):
      bert_summarizer = BertSummarizer(
          num_heads=4,
          num_layers_encoder=0,
          num_layers_decoder=1,
          feed_forward_dim=20,
          embedding_size_encoder=768,
          embedding_size_decoder=64,
          bert_embedding_encoder="bert-base-uncased",
          embedding_encoder_trainable=True,
          dropout_rate=0,
          max_prediction_len=10,
      )
      bert_summarizer.optimizer_encoder = tf.keras.optimizers.Adam(
          learning_rate=3e-5
      )
      bert_summarizer.optimizer_decoder = tf.keras.optimizers.Adam(
          learning_rate=1e-4
      )
      bert_summarizer.init_model(
          preprocessor=self.preprocessor,
          vectorizer=self.vectorizer,
          embedding_weights_encoder=None,
          embedding_weights_decoder=None,
      )
  
      loss_bert = 0
      train_step = bert_summarizer.new_train_step(
          loss_function=self.loss_func, batch_size=2
      )
      for e in range(0, 10):
          for token_ids, sent_ids, target_ids in self.dataset.take(-1):
              loss_bert = train_step(token_ids, sent_ids, target_ids)
              print(str(loss_bert))
  
      self.assertAlmostEqual(0.07848279923200607, float(loss_bert), 6)
      model_output = bert_summarizer.predict_vectors("I love dogs.", "")
      expected_first_logits = np.array(
          [-1.881355, -1.493431, 1.358053, 3.050439, 0.636483]
      )
      np.testing.assert_allclose(
          expected_first_logits, model_output["logits"][0], atol=1e-3
      )
      self.assertEqual(
          "[CLS] I love dogs. [SEP]",
          model_output["preprocessed_text"][0],
      )
      self.assertEqual("Dogs. [SEP]", model_output["predicted_text"])
  
file_path: headliner/tests/test_bert_training.py
imports: import unittest
  import numpy
  import tensorflow
  from spacy.lang.en import English
  from transformers import BertTokenizer
  from headliner.losses import masked_crossentropy
  from headliner.model.bert_summarizer import BertSummarizer
  from headliner.preprocessing.bert_preprocessor import BertPreprocessor
  from headliner.preprocessing.bert_vectorizer import BertVectorizer
  from headliner.preprocessing.dataset_generator import DatasetGenerator
  from headliner.preprocessing.keras_tokenizer import KerasTokenizer
label_desc: Use image node_id 2 for calling the TestBertTraining obj's underlying member method code with example usage: obj.test_training_summarizer_bert() without return types