Context is important - you need to also share where you wrote this code.
It is likely this error is because you put this code outside of a function. It looks like the code from the official tutorial - if this is the case, this code should be indented so that it's inside the _process()
function just like the code above it.