class_docstr: Constructs a Pop2Piano tokenizer. This tokenizer does not require training.
  
  This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
  this superclass for more information regarding those methods.
  
  Args:
      vocab (`str`):
          Path to the vocab file which contains the vocabulary.
      default_velocity (`int`, *optional*, defaults to 77):
          Determines the default velocity to be used while creating midi Notes.
      num_bars (`int`, *optional*, defaults to 2):
          Determines cutoff_time_idx in for each token.
docstr: This is the `encode_plus` method for `Pop2PianoTokenizer`. It converts the midi notes to the transformer
  generated token ids. It only works on a single batch, to process multiple batches please use
  `batch_encode_plus` or `__call__` method.
  
  Args:
      notes (`numpy.ndarray` of shape `[sequence_length, 4]` or `list` of `pretty_midi.Note` objects):
          This represents the midi notes. If `notes` is a `numpy.ndarray`:
              - Each sequence must have 4 values, they are `onset idx`, `offset idx`, `pitch` and `velocity`.
          If `notes` is a `list` containing `pretty_midi.Note` objects:
              - Each sequence must have 4 attributes, they are `start`, `end`, `pitch` and `velocity`.
      truncation_strategy ([`~tokenization_utils_base.TruncationStrategy`], *optional*):
          Indicates the truncation strategy that is going to be used during truncation.
      max_length (`int`, *optional*):
          Maximum length of the returned list and optionally padding length (see above).
  
  Returns:
      `BatchEncoding` containing the tokens ids.
docstr_tok: ["This","is","the","`","encode_plus","`","method","for","`","Pop2PianoTokenizer","`",".","It","converts","the","midi","notes","to","the","transformer","generated","token","ids",".","It","only","works","on","a","single","batch",",","to","process","multiple","batches","please","use","`","batch_encode_plus","`","or","`","__call__","`","method",".","Args",":","notes","(","`","numpy.ndarray","`","of","shape","`","[","sequence_length",",","4","]","`","or","`","list","`","of","`","pretty_midi.Note","`","objects",")",":","This","represents","the","midi","notes",".","If","`","notes","`","is","a","`","numpy.ndarray","`",":","-","Each","sequence","must","have","4","values",",","they","are","`","onset","idx","`",",","`","offset","idx","`",",","`","pitch","`","and","`","velocity","`",".","If","`","notes","`","is","a","`","list","`","containing","`","pretty_midi.Note","`","objects",":","-","Each","sequence","must","have","4","attributes",",","they","are","`","start","`",",","`","end","`",",","`","pitch","`","and","`","velocity","`",".","truncation_strategy","(","[","`","~tokenization_utils_base.TruncationStrategy","`","]",",","*","optional","*",")",":","Indicates","the","truncation","strategy","that","is","going","to","be","used","during","truncation",".","max_length","(","`","int","`",",","*","optional","*",")",":","Maximum","length","of","the","returned","list","and","optionally","padding","length","(","see","above",")",".","Returns",":","`","BatchEncoding","`","containing","the","tokens","ids","."]
code: def encode_plus(
      self,
      notes: Union[np.ndarray, List[pretty_midi.Note]],
      truncation_strategy: Optional[TruncationStrategy] = None,
      max_length: Optional[int] = None,
      **kwargs,
  ) -> BatchEncoding:
      r"""
      This is the `encode_plus` method for `Pop2PianoTokenizer`. It converts the midi notes to the transformer
      generated token ids. It only works on a single batch, to process multiple batches please use
      `batch_encode_plus` or `__call__` method.
  
      Args:
          notes (`numpy.ndarray` of shape `[sequence_length, 4]` or `list` of `pretty_midi.Note` objects):
              This represents the midi notes. If `notes` is a `numpy.ndarray`:
                  - Each sequence must have 4 values, they are `onset idx`, `offset idx`, `pitch` and `velocity`.
              If `notes` is a `list` containing `pretty_midi.Note` objects:
                  - Each sequence must have 4 attributes, they are `start`, `end`, `pitch` and `velocity`.
          truncation_strategy ([`~tokenization_utils_base.TruncationStrategy`], *optional*):
              Indicates the truncation strategy that is going to be used during truncation.
          max_length (`int`, *optional*):
              Maximum length of the returned list and optionally padding length (see above).
  
      Returns:
          `BatchEncoding` containing the tokens ids.
      """
  
      requires_backends(self, ["pretty_midi"])
  
      # check if notes is a pretty_midi object or not, if yes then extract the attributes and put them into a numpy
      # array.
      if isinstance(notes[0], pretty_midi.Note):
          notes = np.array(
              [
                  [
                      each_note.start,
                      each_note.end,
                      each_note.pitch,
                      each_note.velocity,
                  ]
                  for each_note in notes
              ]
          ).reshape(-1, 4)
  
      # to round up all the values to the closest int values.
      notes = np.round(notes).astype(np.int32)
      max_time_idx = notes[:, :2].max()
  
      times = [[] for i in range((max_time_idx + 1))]
      for onset, offset, pitch, velocity in notes:
          times[onset].append([pitch, velocity])
          times[offset].append([pitch, 0])
  
      tokens = []
      current_velocity = 0
      for i, time in enumerate(times):
          if len(time) == 0:
              continue
          tokens.append(self._convert_token_to_id(i, "TOKEN_TIME"))
          for pitch, velocity in time:
              velocity = int(velocity > 0)
              if current_velocity != velocity:
                  current_velocity = velocity
                  tokens.append(
                      self._convert_token_to_id(
                          velocity, "TOKEN_VELOCITY"
                      )
                  )
              tokens.append(
                  self._convert_token_to_id(pitch, "TOKEN_NOTE")
              )
  
      total_len = len(tokens)
  
      # truncation
      if (
          truncation_strategy != TruncationStrategy.DO_NOT_TRUNCATE
          and max_length
          and total_len > max_length
      ):
          tokens, _, _ = self.truncate_sequences(
              ids=tokens,
              num_tokens_to_remove=total_len - max_length,
              truncation_strategy=truncation_strategy,
              **kwargs,
          )
  
      return BatchEncoding({"token_ids": tokens})
  
imports: import json
  import os
  from typing import List, Optional, Tuple, Union
  import numpy
  from ...feature_extraction_utils import BatchFeature
  from ...tokenization_utils import AddedToken, BatchEncoding, PaddingStrategy, PreTrainedTokenizer, TruncationStrategy
  from ...utils import TensorType, is_pretty_midi_available, logging, requires_backends, to_numpy
label_desc: Use image node_id 11 for calling the Pop2PianoTokenizer obj's underlying member method code with example usage: obj.encode_plus(notes, truncation_strategy, max_length) and returns: BatchEncoding