We have to convert Ref to primitive data type when assigning value.
Otherwise exception threw:
System.Exception: Inconsistent values for attr 'T' DT_INT32 vs. DT_INT32_REF while building NodeDef 'x/read' using Op<name=Identity; signature=input:T -> output:T; attr=T:type>