code: private BufferedImage restoreRGBImage(INDArray tensor3D) {
          INDArray arrayR = null;
          INDArray arrayG = null;
          INDArray arrayB = null;
  
          // entry for 3D input vis
          if (tensor3D.shape()[0] == 3) {
              arrayR = tensor3D.tensorAlongDimension(2, 2, 1);
              arrayG = tensor3D.tensorAlongDimension(1, 2, 1);
              arrayB = tensor3D.tensorAlongDimension(0, 2, 1);
          } else {
              // for all other cases input is just black & white, so we just assign the same channel data to RGB, and represent everything as RGB
              arrayB = tensor3D.tensorAlongDimension(0, 2, 1);
              arrayG = arrayB;
              arrayR = arrayB;
          }
  
          BufferedImage imageToRender = new BufferedImage(arrayR.columns(), arrayR.rows(), BufferedImage.TYPE_INT_RGB);
          for (int x = 0; x < arrayR.columns(); x++) {
              for (int y = 0; y < arrayR.rows(); y++) {
                  Color pix = new Color((int) (255 * arrayR.getRow(y).getDouble(x)),
                                  (int) (255 * arrayG.getRow(y).getDouble(x)),
                                  (int) (255 * arrayB.getRow(y).getDouble(x)));
                  int rgb = pix.getRGB();
                  imageToRender.setRGB(x, y, rgb);
              }
          }
          return imageToRender;
      }
docs: Returns RGB image out of 3D tensor
  
  @param tensor3D
  @return