Mat2cell matlab equivalent in tensorflow or pytorch
I have a square matrix and like to break it into some smaller matrices. For example, assume we have a matrix with the shape of [4,4] and would like to convert it into 4 smaller matrices with size [2,2]. 

input:

[9, 9, 9, 9,
 8, 8, 8, 8,
 7, 7, 7, 7,
 6, 6, 6, 6] 


output:

[[9, 9  | [9, 9,
 8, 8]  | 8, 8],
 ---------------
 [7, 7  | [7, 7,
 6, 6]  | 6, 6]] 


Given a tensor with the shape of 4*4 or 1*16 the easiest way to do this is by view function or reshape:

a = torch.tensor([9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6])
# a = a.view(4,4)
a = a.view(2, 2, 2, 2)

# output:
tensor([[[[9, 9],
          [9, 9]],

         [[8, 8],
          [8, 8]]],


        [[[7, 7],
          [7, 7]],

         [[6, 6],
          [6, 6]]]])

