How to threshold each channel in a tensor selectively