padding='max_length' allowing more than max length
I compared my tokenized data with `pad_to_max_length=True` and `padding='max_length'`. My `max_length` was set to 160. However I noticed there were a couple of data that were tokenized more than 160 when I used `padding='max_length'` versus `pad_to_max_length=True`
Could you post a short code snippet so we can reproduce ?<|||||>> Could you post a short code snippet so we can reproduce ?

This is my code.

```
class GPReviewDataset(Dataset):
    def __init__(self, reviews, targets, tokenizer, max_len):
        self.reviews = reviews
        self.targets = targets
        self.tokenizer = tokenizer
        self.max_len = max_len
        
    def __len__(self):
        return len(self.reviews)
    
    def __getitem__(self, item):
        review = str(self.reviews[item])
        target = self.targets[item]
        
        encoding = self.tokenizer.encode_plus(text=review, max_length=self.max_len,
                                         add_special_tokens=True, padding='max_length', 
                                         return_attention_mask=True, 
                                         return_token_type_ids=False, return_tensors='pt')
        
        return {'review': review,
                'input_ids': encoding['input_ids'].flatten(), 
                'attention_mask': encoding['attention_mask'].flatten(),
                'targets': torch.tensor(target, dtype=torch.long)}


error_list = []

for i in range(len(free_df)):
    if len(GPReviewDataset(free_df['content'].to_numpy(), free_df['score'].to_numpy(), tokenizer, 160).__getitem__(i)['attention_mask']) != 160:
        error_list.append((i, len(GPReviewDataset(free_df['content'].to_numpy(), free_df['score'].to_numpy(), tokenizer, 160).__getitem__(i)['input_ids'])))
        
error_list
```

and the results
```
[(95, 184),
 (948, 218),
 (1025, 162),
 (3679, 204),
 (3680, 164),
 (4150, 220),
 (6139, 185),
 (7139, 165),
 (7201, 166),
 (7237, 256),
 (7381, 181),
 (7599, 254),
 (7600, 204),
 (7679, 170),
 (8111, 202),
 (8378, 193),
 (8773, 583),
 (9041, 583),
 (9321, 161),
 (10466, 279)]
```<|||||>You should set your truncation parameter as well, otherwise it won't truncate the texts that are too long. See the docs about the tokenizer methods  [here (look for `truncation`)](https://huggingface.co/transformers/internal/tokenization_utils.html?highlight=truncation#transformers.tokenization_utils_base.PreTrainedTokenizerBase.__call__)<|||||>> You should set your truncation parameter as well, otherwise it won't truncate the texts that are too long. See the docs about the tokenizer methods [here (look for `truncation`)](https://huggingface.co/transformers/internal/tokenization_utils.html?highlight=truncation#transformers.tokenization_utils_base.PreTrainedTokenizerBase.__call__)

Thank you! That worked.