def create_and_check_albert_for_pretraining(
     self, config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
 ):
     config.num_labels = self.num_labels
     model = TFAlbertForPreTraining(config=config)
     inputs = {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
     result = model(inputs)
     self.parent.assertEqual(result.prediction_logits.shape, (self.batch_size, self.seq_length, self.vocab_size))
     self.parent.assertEqual(result.sop_logits.shape, (self.batch_size, self.num_labels))
    def test_inference_masked_lm(self):
        model = TFAlbertForPreTraining.from_pretrained("albert-base-v2")
        input_ids = tf.constant([[0, 1, 2, 3, 4, 5]])
        output = model(input_ids)[0]

        expected_shape = [1, 6, 30000]
        self.assertEqual(output.shape, expected_shape)

        expected_slice = tf.constant([[
            [4.595668, 0.74462754, -1.818147],
            [4.5954347, 0.7454184, -1.8188258],
            [4.5954905, 0.7448235, -1.8182316],
        ]])
        tf.debugging.assert_near(output[:, :3, :3], expected_slice, atol=1e-4)