code: public static Pair<INDArray, INDArray> mergeFeatures(@NonNull INDArray[] featuresToMerge,
                      INDArray[] featureMasksToMerge) {
          Preconditions.checkNotNull(featuresToMerge[0], "Encountered null feature array when merging");
          int rankFeatures = featuresToMerge[0].rank();
  
          switch (rankFeatures) {
              case 2:
                  return DataSetUtil.merge2d(featuresToMerge, featureMasksToMerge);
              case 3:
                  return DataSetUtil.mergeTimeSeries(featuresToMerge, featureMasksToMerge);
              case 4:
                  return DataSetUtil.merge4d(featuresToMerge, featureMasksToMerge);
              default:
                  throw new IllegalStateException("Cannot merge examples: features rank must be in range 2 to 4"
                                  + " inclusive. First example features shape: "
                                  + Arrays.toString(featuresToMerge[0].shape()));
          }
      }
docs: Merge the specified features and mask arrays (i.e., concatenate the examples)
  
  @param featuresToMerge     Features to merge
  @param featureMasksToMerge Mask arrays to merge. May be null
  @return Merged features and mask. Mask may be null