<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, filename):
 """ Write the multitrack pianoroll to a MIDI file. Parameters filename : str The name of the MIDI file to which the multitrack pianoroll is written. """

        if not filename.endswith(('.mid', '.midi', '.MID', '.MIDI')):
            filename = filename + '.mid'
        pm = self.to_pretty_midi()
        pm.write(filename)