docs: public static Pair<INDArray, INDArray> merge4d(INDArray[] arrays, INDArray[] masks) {
          //4d -> images. In principle: could have 2d mask arrays (per-example masks)
  
          int nExamples = 0;
          long[] shape = arrays[0].shape();
          INDArray[] temp = new INDArray[arrays.length];
          boolean hasMasks = false;
          int maskRank = -1;
          for (int i = 0; i < arrays.length; i++) {
              Preconditions.checkNotNull(arrays[i], "Encountered null array when merging data at position %s", i);
              nExamples += arrays[i].size(0);
              long[] thisShape = arrays[i].shape();
              if (thisShape.length != 4) {
                  throw new IllegalStateException("Cannot merge 4d arrays with non 4d arrays");
              }
              for (int j = 1; j < 4; j++) {
                  if (thisShape[j] != shape[j])
                      throw new IllegalStateException(
                                      "Cannot merge 4d arrays with different shape (other than # examples): "
                                                      + " data[0].shape = " + Arrays.toString(shape) + ", data[" + i
                                                      + "].shape = " + Arrays.toString(thisShape));
              }
  
              temp[i] = arrays[i];
              if (masks != null && masks[i] != null ) {
                  hasMasks = true;
                  maskRank = masks[i].rank();
              }
          }
  
          INDArray out = Nd4j.specialConcat(0, temp);
          INDArray outMask = null;
          if (hasMasks) {
              if(maskRank == 2) {
                  outMask = DataSetUtil.mergeMasks2d(out.shape(), arrays, masks);
              } else if(maskRank == 4){
                  outMask = DataSetUtil.mergeMasks4d(arrays, masks);
              }
          }
  
          return new Pair<>(out, outMask);
      }