@Override
    protected OrderedTensorType lazyGetType() {
        if ( ! allInputTypesPresent(1)) return null;

        OrderedTensorType inputType = inputs.get(0).type().get();

        reduceDimensions = inputType.dimensionNames();  // default is to reduce all dimensions
        if (attributeMap.getList("axes").isPresent()) {
            reduceDimensions = new ArrayList<>();
            for (Value i : attributeMap.getList("axes").get()) {
                int dimensionIndex = (int) i.asDouble();
                if (dimensionIndex < 0) {
                    dimensionIndex = inputType.dimensions().size() + dimensionIndex;
                }
                reduceDimensions.add(inputType.dimensions().get(dimensionIndex).name());
            }
        }
        return reducedType(inputType, shouldKeepDimensions());
    }
ONNX Reduce[Sum/Mean/etc] operation
model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Reduce.java