code: def test_encode_plus_with_padding(self):
      tokenizers = self.get_tokenizers(do_lower_case=False)
      for tokenizer in tokenizers:
          with self.subTest(f"{tokenizer.__class__.__name__}"):
              table = self.get_table(tokenizer, length=0)
              sequence = "Sequence"
  
              # check correct behaviour if no pad_token_id exists and add it eventually
              self._check_no_pad_token_padding(tokenizer, sequence)
  
              padding_size = 10
              padding_idx = tokenizer.pad_token_id
              token_type_padding_idx = tokenizer.pad_token_type_id
  
              encoded_sequence = tokenizer.encode_plus(
                  table, sequence, return_special_tokens_mask=True
              )
              input_ids = encoded_sequence["input_ids"]
              special_tokens_mask = encoded_sequence[
                  "special_tokens_mask"
              ]
              sequence_length = len(input_ids)
  
              # Test 'longest' and 'no_padding' don't do anything
              tokenizer.padding_side = "right"
  
              not_padded_sequence = tokenizer.encode_plus(
                  table,
                  sequence,
                  padding=False,
                  return_special_tokens_mask=True,
              )
              not_padded_input_ids = not_padded_sequence["input_ids"]
  
              not_padded_special_tokens_mask = not_padded_sequence[
                  "special_tokens_mask"
              ]
              not_padded_sequence_length = len(not_padded_input_ids)
  
              self.assertEqual(
                  sequence_length, not_padded_sequence_length
              )
              self.assertListEqual(input_ids, not_padded_input_ids)
              self.assertListEqual(
                  special_tokens_mask, not_padded_special_tokens_mask
              )
  
              not_padded_sequence = tokenizer.encode_plus(
                  table,
                  sequence,
                  padding=False,
                  return_special_tokens_mask=True,
              )
              not_padded_input_ids = not_padded_sequence["input_ids"]
  
              not_padded_special_tokens_mask = not_padded_sequence[
                  "special_tokens_mask"
              ]
              not_padded_sequence_length = len(not_padded_input_ids)
  
              self.assertEqual(
                  sequence_length, not_padded_sequence_length
              )
              self.assertListEqual(input_ids, not_padded_input_ids)
              self.assertListEqual(
                  special_tokens_mask, not_padded_special_tokens_mask
              )
  
              # Test right padding
              tokenizer.padding_side = "right"
  
              right_padded_sequence = tokenizer.encode_plus(
                  table,
                  sequence,
                  max_length=sequence_length + padding_size,
                  padding="max_length",
                  return_special_tokens_mask=True,
              )
              right_padded_input_ids = right_padded_sequence[
                  "input_ids"
              ]
  
              right_padded_special_tokens_mask = right_padded_sequence[
                  "special_tokens_mask"
              ]
              right_padded_sequence_length = len(right_padded_input_ids)
  
              self.assertEqual(
                  sequence_length + padding_size,
                  right_padded_sequence_length,
              )
              self.assertListEqual(
                  input_ids + [padding_idx] * padding_size,
                  right_padded_input_ids,
              )
              self.assertListEqual(
                  special_tokens_mask + [1] * padding_size,
                  right_padded_special_tokens_mask,
              )
  
              # Test left padding
              tokenizer.padding_side = "left"
              left_padded_sequence = tokenizer.encode_plus(
                  table,
                  sequence,
                  max_length=sequence_length + padding_size,
                  padding="max_length",
                  return_special_tokens_mask=True,
              )
              left_padded_input_ids = left_padded_sequence["input_ids"]
              left_padded_special_tokens_mask = left_padded_sequence[
                  "special_tokens_mask"
              ]
              left_padded_sequence_length = len(left_padded_input_ids)
  
              self.assertEqual(
                  sequence_length + padding_size,
                  left_padded_sequence_length,
              )
              self.assertListEqual(
                  [padding_idx] * padding_size + input_ids,
                  left_padded_input_ids,
              )
              self.assertListEqual(
                  [1] * padding_size + special_tokens_mask,
                  left_padded_special_tokens_mask,
              )
  
              if "token_type_ids" in tokenizer.model_input_names:
                  token_type_ids = encoded_sequence["token_type_ids"]
                  left_padded_token_type_ids = left_padded_sequence[
                      "token_type_ids"
                  ]
                  right_padded_token_type_ids = right_padded_sequence[
                      "token_type_ids"
                  ]
  
                  self.assertListEqual(
                      (
                          token_type_ids
                          + [[token_type_padding_idx] * 7]
                          * padding_size,
                          right_padded_token_type_ids,
                      )
                  )
                  self.assertListEqual(
                      [[token_type_padding_idx] * 7] * padding_size
                      + token_type_ids,
                      left_padded_token_type_ids,
                  )
  
              if "attention_mask" in tokenizer.model_input_names:
                  attention_mask = encoded_sequence["attention_mask"]
                  right_padded_attention_mask = right_padded_sequence[
                      "attention_mask"
                  ]
                  left_padded_attention_mask = left_padded_sequence[
                      "attention_mask"
                  ]
  
                  self.assertListEqual(
                      attention_mask + [0] * padding_size,
                      right_padded_attention_mask,
                  )
                  self.assertListEqual(
                      [0] * padding_size + attention_mask,
                      left_padded_attention_mask,
                  )
  
imports: import json
  import os
  import shutil
  import tempfile
  import unittest
  from typing import List
  import pandas
  from transformers import AddedToken, TapexTokenizer
  from transformers.models.tapex.tokenization_tapex import VOCAB_FILES_NAMES
  from transformers.testing_utils import is_pt_tf_cross_test, require_pandas, slow
  from ...test_tokenization_common import TokenizerTesterMixin
label_desc: Use image node_id 28 for calling the TapexTokenizationTest obj's underlying member method code with example usage: obj.test_encode_plus_with_padding() without return types