Could you post a code snippet to reproduce this issue, please?
You can post code by wrapping it into three backticks ```, which makes debugging easier. 
Based on the error message, if seems you are passing a Python type into the to() method, but it’s hard to help any further without seeing the real code.