def predict_action(self, x, pred, to_numpy=False):
    x = tensor(x)
    q = self(x)
    if (pred == 'max'):
        (max_q, max_q_idx) = q.max((- 1))
        max_actor = max_q.max(0)[1]
        action = q[max_actor].argmax()
    elif (pred == 'rand'):
        idx = np.random.choice(self.particles, 1)[0]
        action = q[idx].max(0)[1]
    elif (pred == 'mean'):
        action_means = q.mean(0)
        action = action_means.argmax()
    if to_numpy:
        action = action.cpu().detach().numpy()
    return action
def predict_action(self, x, pred, to_numpy=False):
    x = tensor(x)
    q = self(x)
    if (pred == 'max'):
        (max_q, max_q_idx) = q.max((- 1))
        max_actor = max_q.max(0)[1]
        action = q[max_actor].argmax()
    elif (pred == 'rand'):
        idx = np.random.choice(self.particles, 1)[0]
        action = q[idx].max(0)[1]
    elif (pred == 'mean'):
        action_means = q.mean(0)
        action = action_means.argmax()
    if to_numpy:
        action = action.cpu().detach().numpy()
    return action