The following should work according to torch.nonzero documentation:
indices = torch.nonzero(cond, as_tuple=True) x[indices]