code: public long[] transposeShapeArray(long[] shape) {
          if (shape.length == 2) {
              return ArrayUtil.reverseCopy(shape);
          } else if (shape.length == 3) {
              return new long[] {shape[0], shape[2], shape[1]};
          } else {
              throw new IllegalArgumentException("Matrix input has to be of length 2 or 3, got: " + shape.length );
          }
  
      }
docs: For a 2D matrix of shape (M, N) we return (N, M).
  For a 3D matrix with leading mini-batch dimension (mb, M, N)
  we return (mb, N, M)
  
  @param shape input shape array
  @return