Solved using this github commit 1
In [11]: import torch

In [12]: a = torch.randn(4, 3, 32, 32)

In [13]: a.size()
Out[13]: torch.Size([4, 3, 32, 32])

In [14]: b = a.view(a.shape[0], -1)

In [15]: b.size()
Out[15]: torch.Size([4, 3072])

In [16]: c = torch.flatten(b)

In [17]: c.size()
Out[17]: torch.Size([12288])

In [18]: 

In [18]: import torch.nn as nn

In [19]: m_linear = nn.Linear(3*32*32, 10)

In [20]: d = m_linear(b)

In [21]: d.size()
Out[21]: torch.Size([4, 10])

In [22]: