<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def flatten(self):
 """ Reshape all dimensions but the last into a single dimension """

        size = prod(self.shape[:-1])
        return self.reshape(size, self.shape[-1])