Thanks for your reply. @ptrblck
I reckon that the problem is  line ‘state = np.concatenate([only_state, desvel.detach().numpy(), uns4IDM.detach().numpy()])’.
but i can’t use just .numpy() or torch.tensor() because this framework accepts only numpy type array.
What should I do in this case?
def getLoss(agent, x_traj, a_traj, c, env, PI_STD, NUM_SAM):
    # getLoss
    logPr = torch.zeros(1)
    logPr_act = torch.zeros(1)
    logPr_lc = torch.zeros(1)
    logPr_acc = torch.zeros(1)

    desvel, uns4IDM = torch.split(c.view(-1),1)

    env.desvel = desvel
    env.uns4IDM = uns4IDM

    for num_it in range(NUM_SAM):
        logPr_ep = torch.zeros(1)
        logPr_act_ep = torch.zeros(1)
        logPr_lc_ep = torch.zeros(1)
        logPr_acc_ep = torch.zeros(1)

        t = torch.zeros(1)
        state = env.reset()
        only_state = np.delete(state, (14, 15))
        state = np.concatenate([only_state, desvel.detach().numpy(), uns4IDM.detach().numpy()])


        print('\ncalculating loss')
        for it, next_x in tqdm(enumerate(x_traj[1:])):
            action = agent.compute_action(state)
            action_t = torch.Tensor(action)


            lc_loss = ((action_t[1] - a_traj[it][1]) ** 2) / (2 * (PI_STD ** 2)) + ((action_t[2] - a_traj[it][2]) ** 2) / (2 * (PI_STD ** 2)) + ((action_t[3] - a_traj[it][3]) ** 2) / (2 * (PI_STD ** 2))# policy

            logPr_acc_ep = acc_loss.sum() + logPr_acc_ep
            logPr_lc_ep = lc_loss.sum() + logPr_lc_ep
            logPr_act_ep = acc_loss.sum() + lc_loss.sum() + logPr_act_ep
            logPr_ep = logPr_ep + acc_loss.sum() + lc_loss.sum()

            next_state, _, _, _ = env.step(action)

            t += 1
            on_state = np.delete(next_state, (14, 15))
            state = np.concatenate([on_state, desvel.detach().numpy(), uns4IDM.detach().numpy()])

        logPr_acc += logPr_acc_ep
        logPr_lc += logPr_lc_ep
        logPr_act += logPr_act_ep
        logPr += logPr_ep
        print("acc:{}, lc:{}, logPr:{}, logPr_act:{}".format(logPr_acc, logPr_lc, logPr_ep, logPr_act))
    return logPr/NUM_SAM, logPr_act/NUM_SAM