code: def test_right_and_left_truncation(self):
      tokenizer = self.tokenizer
      notes = self.get_input_notes()
      notes = notes[0]
      truncation_size = 3
  
      # RIGHT TRUNCATION - Check that it correctly truncates when a maximum length is specified along with the truncation flag set to True
      tokenizer.truncation_side = "right"
      full_encoded_notes = tokenizer(notes)["token_ids"]
      full_encoded_notes_length = len(full_encoded_notes)
      truncated_notes = tokenizer(
          notes,
          max_length=full_encoded_notes_length - truncation_size,
          truncation=True,
      )["token_ids"]
      self.assertEqual(
          full_encoded_notes_length,
          len(truncated_notes) + truncation_size,
      )
      self.assertEqual(
          full_encoded_notes[:-truncation_size], truncated_notes
      )
  
      # LEFT TRUNCATION - Check that it correctly truncates when a maximum length is specified along with the truncation flag set to True
      tokenizer.truncation_side = "left"
      full_encoded_notes = tokenizer(notes)["token_ids"]
      full_encoded_notes_length = len(full_encoded_notes)
      truncated_notes = tokenizer(
          notes,
          max_length=full_encoded_notes_length - truncation_size,
          truncation=True,
      )["token_ids"]
      self.assertEqual(
          full_encoded_notes_length,
          len(truncated_notes) + truncation_size,
      )
      self.assertEqual(
          full_encoded_notes[truncation_size:], truncated_notes
      )
  
      # RIGHT & LEFT TRUNCATION - Check that nothing is done for 'longest' and 'no_truncation'
      tokenizer.truncation_side = "right"
      truncated_notes_right = tokenizer(notes, truncation=True)[
          "token_ids"
      ]
      self.assertEqual(
          full_encoded_notes_length, len(truncated_notes_right)
      )
      self.assertEqual(full_encoded_notes, truncated_notes_right)
  
      tokenizer.truncation_side = "left"
      truncated_notes_left = tokenizer(
          notes, truncation="longest_first"
      )["token_ids"]
      self.assertEqual(
          len(truncated_notes_left), full_encoded_notes_length
      )
      self.assertEqual(truncated_notes_left, full_encoded_notes)
  
      tokenizer.truncation_side = "right"
      truncated_notes_right = tokenizer(
          notes, truncation="longest_first"
      )["token_ids"]
      self.assertEqual(
          len(truncated_notes_right), full_encoded_notes_length
      )
      self.assertEqual(truncated_notes_right, full_encoded_notes)
  
      tokenizer.truncation_side = "left"
      truncated_notes_left = tokenizer(notes, truncation=True)[
          "token_ids"
      ]
      self.assertEqual(
          len(truncated_notes_left), full_encoded_notes_length
      )
      self.assertEqual(truncated_notes_left, full_encoded_notes)
  
imports: import os
  import pickle
  import shutil
  import tempfile
  import unittest
  from transformers.feature_extraction_utils import BatchFeature
  from transformers.testing_utils import is_pretty_midi_available, is_torch_available, require_pretty_midi, require_torch
  from transformers.tokenization_utils import BatchEncoding
label_desc: Use image node_id 12 for calling the Pop2PianoTokenizerTest obj's underlying member method code with example usage: obj.test_right_and_left_truncation() without return types