@Override
    public void assign(Object o) {
        if (o == null) {
            assignTensor(Optional.empty());
        } else if (o instanceof Tensor) {
            assignTensor(Optional.of((Tensor)o));
        } else if (o instanceof TensorFieldValue) {
            var tfv = (TensorFieldValue)o;
            assignTypeFrom(tfv.tensor);
            this.serializedTensor = tfv.serializedTensor;
            this.tensor = tfv.tensor;
        } else {
            throw new IllegalArgumentException("Expected class '" + getClass().getName() + "', got '" +
                                               o.getClass().getName() + "'.");
        }
    }
Create a tensor field value containing the given tensor
document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java