Debug a provided Transformer implementation containing several injected bugs (find and fix them), then convert the model into a classifier by modifying only the final layer, passing a provided test harness.
Asked in the coding_transformer_debug stage. The original prompt described four quickly discoverable bugs and a follow-up requiring the final layer to become a classifier. This portable task uses a standard-library function that reports the classifier output contract.
Implement debug_transformer_classifier(vocab_size, d_model, num_heads, num_layers, num_classes, tokens, padding_mask). tokens is a batch of token IDs, and padding_mask is either null or a matching boolean matrix. Return a dictionary containing output_shape, tokens_shape, and, when padding exists, padding_excluded.
def debug_transformer_classifier(vocab_size, d_model, num_heads, num_layers, num_classes, tokens, padding_mask):