private void assignTypeFrom(Optional<Tensor> newTensor) {
        if (newTensor.isEmpty()) return;
        TensorType newType = newTensor.get().type();
        if (dataType.isEmpty()) {
            this.dataType = Optional.of(new TensorDataType(newType));
        }
        TensorType curType = dataType.get().getTensorType();
        if (! newType.isAssignableTo(curType)) {
            throw new IllegalArgumentException("Type mismatch: Cannot assign tensor of type " + newType + " to field of type " + curType);
        }
    }
Create a tensor field value containing the given tensor
document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java