<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
I have the following torch tensor:
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
t, idx = load_data()
assert type(t) == torch.Tensor
assert type(idx) == np.ndarray
idx = 1 - idx
idxs = torch.from_numpy(idx).long().unsqueeze(1)
# or   torch.from_numpy(idxs).long().view(-1,1)
result = t.gather(1, idxs).squeeze(1)
<END_TASK>