How do I flatten a tensor in pytorch? : <p>Given a tensor of multiple dimensions, how do I flatten it so that it has a single dimension?</p>

<p>Eg:</p>

<pre><code>&gt;&gt;&gt; t = torch.rand([2, 3, 5])
&gt;&gt;&gt; t.shape
torch.Size([2, 3, 5])
</code></pre>

<p>How do I flatten it to have shape:</p>

<pre><code>torch.Size([30])
</code></pre>
