I just did that exactly as what you’ve said, it works!
But there is another question came with it,  would this conversion: Variable -> Tensor -> Variable destroy the chain which conduct the gradient of mask to its creator? Is there some specific cases that the mask is part of the network and this operation should apply gradient to the mask?