docs: public static Pair<INDArray, ByteBuffer> toArrayAndByteBuffer(ByteBuffer buffer, int offset) {
          ByteBuffer byteBuffer = buffer.hasArray() ? ByteBuffer.allocateDirect(buffer.array().length).put(buffer.array())
                  .order(ByteOrder.nativeOrder()) : buffer.order(ByteOrder.nativeOrder());
          //bump the byte buffer to the proper position
          byteBuffer.position(offset);
          int rank = byteBuffer.getInt();
          if (rank < 0)
              throw new IllegalStateException("Found negative integer. Corrupt serialization?");
          //get the shape buffer length to create the shape information buffer
          int shapeBufferLength = Shape.shapeInfoLength(rank);
          //create the ndarray shape information
          DataBuffer shapeBuff = Nd4j.createBufferDetached(new int[shapeBufferLength]);
  
          //compute the databuffer opType from the index
          DataType type = DataType.values()[byteBuffer.getInt()];
          for (int i = 0; i < shapeBufferLength; i++) {
              shapeBuff.put(i, byteBuffer.getLong());
          }
  
          //after the rank,data opType, shape buffer (of length shape buffer length) * sizeof(int)
          if (type != DataType.COMPRESSED) {
              ByteBuffer slice = byteBuffer.slice();
              //wrap the data buffer for the last bit
              // FIXME: int cast
              DataBuffer buff = Nd4j.createBuffer(slice, type, (int) Shape.length(shapeBuff));
              //advance past the data
              int position = byteBuffer.position() + (buff.getElementSize() * (int) buff.length());
              byteBuffer.position(position);
              //create the final array
              //TODO: see how to avoid dup here
              INDArray arr = Nd4j.createArrayFromShapeBuffer(buff.dup(), shapeBuff.dup());
              return Pair.of(arr, byteBuffer);
          } else {
              CompressionDescriptor compressionDescriptor = CompressionDescriptor.fromByteBuffer(byteBuffer);
              ByteBuffer slice = byteBuffer.slice();
              //ensure that we only deal with the slice of the buffer that is actually the data
              BytePointer byteBufferPointer = new BytePointer(slice);
              //create a compressed array based on the rest of the data left in the buffer
              CompressedDataBuffer compressedDataBuffer =
                      new CompressedDataBuffer(byteBufferPointer, compressionDescriptor);
              //TODO: see how to avoid dup()
              INDArray arr = Nd4j.createArrayFromShapeBuffer(compressedDataBuffer.dup(), shapeBuff.dup());
              //advance past the data
              int compressLength = (int) compressionDescriptor.getCompressedLength();
              byteBuffer.position(byteBuffer.position() + compressLength);
              return Pair.of(arr, byteBuffer);
          }
  
      }