<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def unfold(self, mode):
 """ Unfolds a dense tensor in mode n. Parameters mode : int Mode in which tensor is unfolded Returns ------- unfolded_dtensor : unfolded_dtensor object Tensor unfolded along mode Examples -------- Create dense tensor from numpy array Unfolding of dense tensors array([[ 1., 4., 7., 10., 13., 16., 19., 22.], [ 2., 5., 8., 11., 14., 17., 20., 23.], [ 3., 6., 9., 12., 15., 18., 21., 24.]]) array([[ 1., 2., 3., 13., 14., 15.], [ 4., 5., 6., 16., 17., 18.], [ 7., 8., 9., 19., 20., 21.], [ 10., 11., 12., 22., 23., 24.]]) array([[ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.], [ 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24.]]) """


        sz = array(self.shape)
        N = len(sz)
        order = ([mode], from_to_without(N - 1, -1, mode, step=-1, skip=-1))
        newsz = (sz[order[0]][0], prod(sz[order[1]]))
        arr = self.transpose(axes=(order[0] + order[1]))
        arr = arr.reshape(newsz)
        return unfolded_dtensor(arr, mode, self.shape)