def fold(self):
        """
        Recreate original tensor by folding unfolded_sptensor according toc
        ``ten_shape``.

        Returns
        -------
        T : sptensor
            Sparse tensor that is created by refolding according to ``ten_shape``.
        """
        nsubs = zeros((len(self.data), len(self.ten_shape)), dtype=np.int)
        if len(self.rdims) > 0:
            nidx = unravel_index(self.row, self.ten_shape[self.rdims])
            for i in range(len(self.rdims)):
                nsubs[:, self.rdims[i]] = nidx[i]
        if len(self.cdims) > 0:
            nidx = unravel_index(self.col, self.ten_shape[self.cdims])
            for i in range(len(self.cdims)):
                nsubs[:, self.cdims[i]] = nidx[i]
        nsubs = [z.flatten() for z in hsplit(nsubs, len(self.ten_shape))]
        return sptensor(tuple(nsubs), self.data, self.ten_shape)
Recreate original tensor by folding unfolded_sptensor according toc
        ``ten_shape``.

        Returns
        -------
        T : sptensor
            Sparse tensor that is created by refolding according to ``ten_shape``.