public synchronized EmbeddingProjection removeEmbedding(EmbeddingProjection projection) {
        if (projection2Index.isEmpty()) {
            return null;
        }

        var index = projection2Index.remove(projection);

        // remove embedding by concatenating sub lists [0, index) + [index + 1, size),
        // thus size of resulting array is decreased by one
        embeddings = Nd4j.concat(
                0,
                embeddings.get(NDArrayIndex.interval(0, index), NDArrayIndex.all()),
                embeddings.get(NDArrayIndex.interval(index + 1, getSize()), NDArrayIndex.all())
        );

        // shifting (-1) all indexes, greater than current one
        projection2Index.entrySet()
                .stream()
                .filter(entry -> entry.getValue() > index)
                .sorted(Map.Entry.comparingByValue())
                .forEach(e -> projection2Index.replace(e.getKey(), e.getValue(), e.getValue() - 1));

        return projection;
    }
NOTE: current method returns COPY! Each time you invoke it, memory consumed, be careful!

@return copy of underlying embeddings array.
java/api/src/main/java/com/exadel/frs/core/trainservice/cache/EmbeddingCollection.java