<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_frames(self, input, nframes = -1):
 """write data to file. :Parameters: input : ndarray array containing data to write. nframes : int number of frames to write. Notes ----- - One column is one channel (one row per channel after 0.9) - updates the write pointer. - if float are given when the file contains integer data, you should put normalized data (that is the range [-1..1] will be written as the maximum range allowed by the integer bitwidth)."""

        if nframes == -1:
            if input.ndim == 1:
                nframes = input.size
            elif input.ndim == 2:
                nframes = input.shape[0]
            else:
                raise ValueError("Input has to be rank 1 (mono) or rank 2 "\
                                 "(multi-channels)")
        return self._sndfile.write_frames(input[:nframes,...])