Complete the code to import the BERT tokenizer from the transformers library.
from transformers import [1]
The BertTokenizer class is used to tokenize text using BERT's WordPiece method.
Complete the code to load the pretrained BERT tokenizer for 'bert-base-uncased'.
tokenizer = BertTokenizer.[1]('bert-base-uncased')
The from_pretrained method loads a pretrained tokenizer by name.
Fix the error in the code to tokenize the sentence using the tokenizer.
tokens = tokenizer.[1]('Hello, how are you?')
The tokenize method splits the input text into WordPiece tokens.
Fill both blanks to create a dictionary of token ids and attention mask for the input text.
encoded_input = tokenizer('[1]', return_tensors='pt', padding=True, truncation=True) input_ids = encoded_input['[2]']
The first blank is the input text string. The second blank is the key 'input_ids' to get token IDs from the encoded output.
Fill all three blanks to decode token ids back to the original text without special tokens.
decoded_text = tokenizer.[1](encoded_input['[2]'][0], skip_special_tokens=[3])
The decode method converts token IDs back to text. The key is 'input_ids'. Setting skip_special_tokens=True removes tokens like [CLS] and [SEP].