The error says it correctly: You did not define clear_data in your function.
you are not trying to set a value ( clear_data is True means that you are checking if it is True or not, getting a boolean as an output) and you are not returning anything either.
The code should be the following: