title: How to apply the torch.inverse() function of PyTorch to every sample in the batch?
body: <p>This may seem like a basic question, but I am unable to work it through. </p>
  
  <p>In the forward pass of my neural network, I have an output tensor of shape 8x3x3, where 8 is my batch size. We can assume each 3x3 tensor to be a non-singular matrix. I need to find the inverse of these matrices.
  The PyTorch <a href="http://pytorch.org/docs/master/torch.html#torch.inverse" rel="noreferrer">inverse()</a> function only works on square matrices. Since I now have 8x3x3, how do I apply this function to every matrix in the batch in a differentiable manner?</p>
  
  <p>If I iterate through the samples and append the inverses to a python list, which I then convert to a PyTorch tensor, should it be a problem during backprop? (I am asking since converting PyTorch tensors to numpy to perform some operations and then back to a tensor won't compute gradients during backprop for such operations)</p>
  
  <p>I also get the following error when I try to do something like that.</p>
  
  <pre><code>a = torch.arange(0,8).view(-1,2,2)
  b = [m.inverse() for m in a]
  c = torch.FloatTensor(b)
  </code></pre>
  
  <blockquote>
    <p>TypeError: 'torch.FloatTensor' object does not support indexing</p>
  </blockquote>