Somewhere your multiplying a Variable by a tensor when you need to multiply a Variable by a Variable. It’s not clear from your snippet where that is.
This looks like a bug:
result = self.ratio * result + (1-ratio) * result * n

Instead of (1-ratio) you should have (1-self.ratio)