private <T> Optional<T> findByEmbeddingId(UUID embeddingId, Function<Map.Entry<EmbeddingProjection, Integer>, T> func) {
        validImageId(embeddingId);

        return Optional.ofNullable(projection2Index.entrySet()
                .stream()
                .filter(entry ->  embeddingId.equals(entry.getKey().embeddingId()))
                .findFirst()
                .map(func)
                .orElseThrow(IncorrectImageIdException::new));
    }
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