code: def test_right_and_left_padding(self):
      tokenizers = self.get_tokenizers(do_lower_case=False)
      for tokenizer in tokenizers:
          with self.subTest(f"{tokenizer.__class__.__name__}"):
              words, boxes = self.get_words_and_boxes()
              sequence = "Sequence"
              padding_size = 10
  
              # check correct behaviour if no pad_token_id exists and add it eventually
              self._check_no_pad_token_padding(tokenizer, sequence)
  
              padding_idx = tokenizer.pad_token_id
  
              # RIGHT PADDING - Check that it correctly pads when a maximum length is specified along with the padding flag set to True
              tokenizer.padding_side = "right"
              encoded_sequence = tokenizer.encode(words, boxes=boxes)
              sequence_length = len(encoded_sequence)
              padded_sequence = tokenizer.encode(
                  words,
                  boxes=boxes,
                  max_length=sequence_length + padding_size,
                  padding="max_length",
              )
              padded_sequence_length = len(padded_sequence)
              assert (
                  sequence_length + padding_size
                  == padded_sequence_length
              )
              assert (
                  encoded_sequence + [padding_idx] * padding_size
                  == padded_sequence
              )
  
              # LEFT PADDING - Check that it correctly pads when a maximum length is specified along with the padding flag set to True
              tokenizer.padding_side = "left"
              encoded_sequence = tokenizer.encode(words, boxes=boxes)
              sequence_length = len(encoded_sequence)
              padded_sequence = tokenizer.encode(
                  words,
                  boxes=boxes,
                  max_length=sequence_length + padding_size,
                  padding="max_length",
              )
              padded_sequence_length = len(padded_sequence)
              assert (
                  sequence_length + padding_size
                  == padded_sequence_length
              )
              assert [
                  padding_idx
              ] * padding_size + encoded_sequence == padded_sequence
  
              # RIGHT & LEFT PADDING - Check that nothing is done for 'longest' and 'no_padding'
              encoded_sequence = tokenizer.encode(words, boxes=boxes)
              sequence_length = len(encoded_sequence)
  
              tokenizer.padding_side = "right"
              padded_sequence_right = tokenizer.encode(
                  words, boxes=boxes, padding=True
              )
              padded_sequence_right_length = len(padded_sequence_right)
              assert sequence_length == padded_sequence_right_length
              assert encoded_sequence == padded_sequence_right
  
              tokenizer.padding_side = "left"
              padded_sequence_left = tokenizer.encode(
                  words, boxes=boxes, padding="longest"
              )
              padded_sequence_left_length = len(padded_sequence_left)
              assert sequence_length == padded_sequence_left_length
              assert encoded_sequence == padded_sequence_left
  
              tokenizer.padding_side = "right"
              padded_sequence_right = tokenizer.encode(
                  words, boxes=boxes
              )
              padded_sequence_right_length = len(padded_sequence_right)
              assert sequence_length == padded_sequence_right_length
              assert encoded_sequence == padded_sequence_right
  
              tokenizer.padding_side = "left"
              padded_sequence_left = tokenizer.encode(
                  words, boxes=boxes, padding=False
              )
              padded_sequence_left_length = len(padded_sequence_left)
              assert sequence_length == padded_sequence_left_length
              assert encoded_sequence == padded_sequence_left
  
imports: import inspect
  import shutil
  import tempfile
  import unittest
  from typing import List
  from transformers import AddedToken, LayoutXLMTokenizerFast, SpecialTokensMixin, is_tf_available, is_torch_available, logging
  from transformers.models.layoutxlm.tokenization_layoutxlm import LayoutXLMTokenizer
  from transformers.testing_utils import get_tests_dir, is_pt_tf_cross_test, require_pandas, require_scatter, require_sentencepiece, require_tokenizers, require_torch, slow
  from ...test_tokenization_common import SMALL_TRAINING_CORPUS, TokenizerTesterMixin, filter_non_english, merge_model_tokenizer_mappings
label_desc: Use image node_id 31 for calling the LayoutXLMTokenizationTest obj's underlying member method code with example usage: obj.test_right_and_left_padding() without return types