code: def write(self, filename):
          
          if not filename.endswith(('.mid', '.midi', '.MID', '.MIDI')):
              filename = filename + '.mid'
          pm = self.to_pretty_midi()
          pm.write(filename)
docs: Write the multitrack pianoroll to a MIDI file.
  
          Parameters
          ----------
          filename : str
              The name of the MIDI file to which the multitrack pianoroll is
              written.