private static void validate(TensorType type, DimensionSizes sizes) {
            // validate
            if (sizes.dimensions() != type.dimensions().size())
                throw new IllegalArgumentException(sizes.dimensions() +
                        " is the wrong number of dimensions for " + type);
            for (int i = 0; i < sizes.dimensions(); i++ ) {
                Optional<Long> size = type.dimensions().get(i).size();
                if (size.isPresent() && size.get() < sizes.size(i))
                    throw new IllegalArgumentException("Size of dimension " + type.dimensions().get(i).name() + " is " +
                            sizes.size(i) +
                            " but cannot be larger than " + size.get() + " in " + type);
            }
        }
Creates a builder initialized with the given values

@param type the type of the tensor to build
@param values the initial values of the tensor in the <i>standard value order</i>.
              This <b>transfers ownership</b> of the value array - it
              must not be further mutated by the caller
vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java