title: squeeze and unsqueeze tensor in Android (Java)
body: <p>I am trying to port my torchscript over from Python to Android (Java). Currently, I ran into a problem of trying to squeeze/ unsqueeze my input and output tensor in Android. In Python, here's how I did it:</p>
  <pre><code>**tensor = torch.Tensor(image_n.transpose(2, 0, 1).astype('float32')).unsqueeze(0)
  tensor = tensor.to(device)** 
  </code></pre>
  <p>output tensor:</p>
  <pre><code> **with torch.no_grad():
      prob = model.forward(tensor)
      prediction = prob.squeeze().numpy().astype('uint8')**
  </code></pre>
  <p>In Android, I managed to input and output my tensors following the Pytorch tutorial as such:</p>
  <pre><code>**final Tensor inputTensor = TensorImageUtils.bitmapToFloat32Tensor(mBitmap,
              TensorImageUtils.TORCHVISION_NORM_MEAN_RGB, TensorImageUtils.TORCHVISION_NORM_STD_RGB);
    final float[] inputs = inputTensor.getDataAsFloatArray();**
  </code></pre>
  <p>and the output tensor:</p>
  <pre><code>**Map&lt;String, IValue&gt; outTensors = mModule.forward(IValue.from(inputTensor)).toDictStringKey();**
  </code></pre>
  <p>The problem is, without squeeze and unsqueeze, although the code managed to run, the dimensions are wrong and I didnt manage to get the correct output.</p>
  <p>Does anyone know if there is actually squeeze/unsqueeze function for pytorch in Android?</p>
  <p>Edit: just to add on, my input tensor has the size of (3,224,416) (an RGB image), and my out put tensor has the size of (1,1,224,416) (a grayscale image)</p>