class_docstr: Converts to/from multiple-instrument metric performances.
  
  Attributes:
    num_velocity_bins: Number of velocity bins.
    max_tensors_per_notesequence: The maximum number of outputs to return
        for each NoteSequence.
    hop_size_bars: How many bars each sequence should be.
    chunk_size_bars: Chunk size used for hierarchically decomposing sequence.
    steps_per_quarter: Number of time steps per quarter note.
    quarters_per_bar: Number of quarter notes per bar.
    min_num_instruments: Minimum number of instruments per sequence.
    max_num_instruments: Maximum number of instruments per sequence.
    min_total_events: Minimum total length of all performance tracks, in events.
    max_events_per_instrument: Maximum length of a single-instrument
        performance, in events.
    first_subsequence_only: If True, only use the very first hop and discard all
        sequences longer than the hop size.
    chord_encoding: An instantiated OneHotEncoding object to use for encoding
        chords on which to condition, or None if not conditioning on chords.
    drop_tracks_and_truncate: Randomly drop extra tracks and truncate the event
        sequence.
class_docstr_tok: ["Converts","to\/from","multiple-instrument","metric","performances",".","Attributes",":","num_velocity_bins",":","Number","of","velocity","bins",".","max_tensors_per_notesequence",":","The","maximum","number","of","outputs","to","return","for","each","NoteSequence",".","hop_size_bars",":","How","many","bars","each","sequence","should","be",".","chunk_size_bars",":","Chunk","size","used","for","hierarchically","decomposing","sequence",".","steps_per_quarter",":","Number","of","time","steps","per","quarter","note",".","quarters_per_bar",":","Number","of","quarter","notes","per","bar",".","min_num_instruments",":","Minimum","number","of","instruments","per","sequence",".","max_num_instruments",":","Maximum","number","of","instruments","per","sequence",".","min_total_events",":","Minimum","total","length","of","all","performance","tracks",",","in","events",".","max_events_per_instrument",":","Maximum","length","of","a","single-instrument","performance",",","in","events",".","first_subsequence_only",":","If","True",",","only","use","the","very","first","hop","and","discard","all","sequences","longer","than","the","hop","size",".","chord_encoding",":","An","instantiated","OneHotEncoding","object","to","use","for","encoding","chords","on","which","to","condition",",","or","None","if","not","conditioning","on","chords",".","drop_tracks_and_truncate",":","Randomly","drop","extra","tracks","and","truncate","the","event","sequence","."]
code: def __init__(
      self,
      num_velocity_bins=0,
      max_tensors_per_notesequence=None,
      hop_size_bars=1,
      chunk_size_bars=1,
      steps_per_quarter=24,
      quarters_per_bar=4,
      min_num_instruments=2,
      max_num_instruments=8,
      min_total_events=8,
      max_events_per_instrument=64,
      min_pitch=performance_lib.MIN_MIDI_PITCH,
      max_pitch=performance_lib.MAX_MIDI_PITCH,
      first_subsequence_only=False,
      chord_encoding=None,
      drop_tracks_and_truncate=False,
  ):
      max_shift_steps = (
          performance_lib.DEFAULT_MAX_SHIFT_QUARTERS * steps_per_quarter
      )
  
      self._performance_encoding = note_seq.PerformanceOneHotEncoding(
          num_velocity_bins=num_velocity_bins,
          max_shift_steps=max_shift_steps,
          min_pitch=min_pitch,
          max_pitch=max_pitch,
      )
      self._chord_encoding = chord_encoding
  
      self._num_velocity_bins = num_velocity_bins
      self._hop_size_bars = hop_size_bars
      self._chunk_size_bars = chunk_size_bars
      self._steps_per_quarter = steps_per_quarter
      self._steps_per_bar = steps_per_quarter * quarters_per_bar
      self._min_num_instruments = min_num_instruments
      self._max_num_instruments = max_num_instruments
      self._min_total_events = min_total_events
      self._max_events_per_instrument = max_events_per_instrument
      self._min_pitch = min_pitch
      self._max_pitch = max_pitch
      self._first_subsequence_only = first_subsequence_only
      self._drop_tracks_and_truncate = drop_tracks_and_truncate
  
      self._max_num_chunks = hop_size_bars // chunk_size_bars
      self._max_steps_truncate = (
          steps_per_quarter * quarters_per_bar * hop_size_bars
      )
  
      # Each encoded track will begin with a program specification token
      # (with one extra program for drums).
      num_program_tokens = (
          note_seq.MAX_MIDI_PROGRAM - note_seq.MIN_MIDI_PROGRAM + 2
      )
      end_token = (
          self._performance_encoding.num_classes + num_program_tokens
      )
      depth = end_token + 1
  
      max_lengths = [
          self._max_num_chunks,
          max_num_instruments,
          max_events_per_instrument,
      ]
      if chord_encoding is None:
          control_depth = 0
          control_pad_token = None
      else:
          control_depth = chord_encoding.num_classes
          control_pad_token = chord_encoding.encode_event(
              note_seq.NO_CHORD
          )
  
      super(MultiInstrumentPerformanceConverter, self).__init__(
          input_depth=depth,
          input_dtype=bool,
          output_depth=depth,
          output_dtype=bool,
          control_depth=control_depth,
          control_dtype=bool,
          control_pad_token=control_pad_token,
          end_token=end_token,
          max_lengths=max_lengths,
          max_tensors_per_notesequence=max_tensors_per_notesequence,
      )
  
imports: import abc
  import random
  from magenta.models.music_vae import data
  from magenta.pipelines import performance_pipeline
  import note_seq
  from note_seq import chords_lib
  from note_seq import performance_lib
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 to create a new MultiInstrumentPerformanceConverter object from inherited base classes: BaseHierarchicalNoteSequenceConverter with example: obj = MultiInstrumentPerformanceConverter(num_velocity_bins, max_tensors_per_notesequence, hop_size_bars, chunk_size_bars, steps_per_quarter, quarters_per_bar, min_num_instruments, max_num_instruments, min_total_events, max_events_per_instrument, min_pitch, max_pitch, first_subsequence_only, chord_encoding, drop_tracks_and_truncate)