code: def testEncode(self):
      encoder = music_encoders.MidiPerformanceEncoder(
          steps_per_second=100,
          num_velocity_bins=32,
          min_pitch=21,
          max_pitch=108,
          ngrams=[(277, 129)],
      )
  
      ns = note_seq.NoteSequence()
      testing_lib.add_track_to_sequence(ns, 0, [(60, 97, 0.0, 1.0)])
  
      # Write NoteSequence to MIDI file as encoder takes in filename.
      with tempfile.NamedTemporaryFile(suffix=".mid") as f:
          note_seq.sequence_proto_to_midi_file(ns, f.name)
          ids = encoder.encode(f.name)
  
      expected_ids = [
          302,  # VELOCITY(25)
          41,  # NOTE-ON(60)
          310,  # TIME-SHIFT(100), NOTE-OFF(60)
      ]
  
      self.assertEqual(expected_ids, ids)
  
imports: import tempfile
  from magenta.models.score2perf import music_encoders
  import note_seq
  from note_seq import testing_lib
  import tensorflow.compat.v1
label_desc: Use image node_id 7 for calling the MidiPerformanceEncoderTest obj's underlying member method code with example usage: obj.testEncode() without return types