to answer your second question, you can create a mask tensor and index elements via this mask tensor:
example:
import torch

x = torch.randn(2, 3, 2)

mask = x.gt(0.5)
print(mask)

# mask is a torch.ByteTensor of same shape and size as x

print(x[mask])

Output:

(0 ,.,.) =
  0  0
  0  0
  0  1

(1 ,.,.) =
  0  1
  1  0
  1  0
[torch.ByteTensor of size 2x3x2]


 1.3140
 0.8220
 1.5169
 0.9264
[torch.FloatTensor of size 4]