def test(self, epoch=0):
    self.model.eval()
    frame_ids = self.cfg.frame_ids
    total_loss = np.zeros((len(define_actions_cmu('all')), len(frame_ids)))
    for (act_idx, act) in enumerate(define_actions_cmu('all')):
        count = 0
        for (i, (inputs, gts)) in enumerate(self.test_loader[act]):
            (b, cv, t_len) = inputs[list(inputs.keys())[0]].shape
            for k in inputs:
                inputs[k] = inputs[k].float().cuda(non_blocking=True, device=self.cfg.device)
                gts[k] = gts[k].float().cuda(non_blocking=True, device=self.cfg.device)
            with torch.no_grad():
                outputs = self.model(inputs)
                for k in outputs:
                    outputs[k] = ((outputs[k] + 1) / 2)
                    outputs[k] = ((outputs[k] * (self.global_max - self.global_min)) + self.global_min)
                    outputs[k] = reverse_dct_torch(outputs[k], self.i_dct_m, self.cfg.seq_len)
                mygt = gts['p32'].view((- 1), self.cfg.origin_noden, 3, self.cfg.seq_len).clone()
                myout = outputs['p22'].view((- 1), self.cfg.final_out_noden, 3, self.cfg.seq_len)
                mygt[:, self.cfg.dim_used_3d, :, :] = myout
                mygt[:, self.cfg.dim_repeat_32, :, :] = myout[:, self.cfg.dim_repeat_22, :, :]
                mygt = mygt.view((- 1), (self.cfg.origin_noden * 3), self.cfg.seq_len)
                loss = L2NormLoss_test(gts['p32'][:, :, self.cfg.input_n:], mygt[:, :, self.cfg.input_n:], self.cfg.frame_ids)
                total_loss[act_idx] += loss
                count += mygt.shape[0]
                if ((act_idx == 0) and (i == 0)):
                    pred_seq = outputs['p22'].cpu().data.numpy()[0].reshape(self.cfg.final_out_noden, 3, self.cfg.seq_len)
                    gt_seq = gts['p22'].cpu().data.numpy()[0].reshape(self.cfg.final_out_noden, 3, self.cfg.seq_len)
                    for t in range(self.cfg.seq_len):
                        draw_pic_gt_pred(gt_seq[:, :, t], pred_seq[:, :, t], self.cfg.I22_plot, self.cfg.J22_plot, self.cfg.LR22_plot, os.path.join(self.cfg.ckpt_dir, 'images', f'{epoch}_{act}_{t}.png'))
        total_loss[act_idx] /= count
        for (fidx, frame) in enumerate(frame_ids):
            self.summary.add_scalar(f'Test/{act}/{frame}', total_loss[act_idx][fidx], epoch)
    self.summary.add_scalar('Test/average', np.mean(total_loss), epoch)
    for (fidx, frame) in enumerate(frame_ids):
        self.summary.add_scalar(f'Test/avg{frame}', np.mean(total_loss[:, fidx]), epoch)
    return total_loss
def test(self, epoch=0):
    self.model.eval()
    frame_ids = self.cfg.frame_ids
    total_loss = np.zeros((len(define_actions_cmu('all')), len(frame_ids)))
    for (act_idx, act) in enumerate(define_actions_cmu('all')):
        count = 0
        for (i, (inputs, gts)) in enumerate(self.test_loader[act]):
            (b, cv, t_len) = inputs[list(inputs.keys())[0]].shape
            for k in inputs:
                inputs[k] = inputs[k].float().cuda(non_blocking=True, device=self.cfg.device)
                gts[k] = gts[k].float().cuda(non_blocking=True, device=self.cfg.device)
            with torch.no_grad():
                outputs = self.model(inputs)
                for k in outputs:
                    outputs[k] = ((outputs[k] + 1) / 2)
                    outputs[k] = ((outputs[k] * (self.global_max - self.global_min)) + self.global_min)
                    outputs[k] = reverse_dct_torch(outputs[k], self.i_dct_m, self.cfg.seq_len)
                mygt = gts['p32'].view((- 1), self.cfg.origin_noden, 3, self.cfg.seq_len).clone()
                myout = outputs['p22'].view((- 1), self.cfg.final_out_noden, 3, self.cfg.seq_len)
                mygt[:, self.cfg.dim_used_3d, :, :] = myout
                mygt[:, self.cfg.dim_repeat_32, :, :] = myout[:, self.cfg.dim_repeat_22, :, :]
                mygt = mygt.view((- 1), (self.cfg.origin_noden * 3), self.cfg.seq_len)
                loss = L2NormLoss_test(gts['p32'][:, :, self.cfg.input_n:], mygt[:, :, self.cfg.input_n:], self.cfg.frame_ids)
                total_loss[act_idx] += loss
                count += mygt.shape[0]
                if ((act_idx == 0) and (i == 0)):
                    pred_seq = outputs['p22'].cpu().data.numpy()[0].reshape(self.cfg.final_out_noden, 3, self.cfg.seq_len)
                    gt_seq = gts['p22'].cpu().data.numpy()[0].reshape(self.cfg.final_out_noden, 3, self.cfg.seq_len)
                    for t in range(self.cfg.seq_len):
                        draw_pic_gt_pred(gt_seq[:, :, t], pred_seq[:, :, t], self.cfg.I22_plot, self.cfg.J22_plot, self.cfg.LR22_plot, os.path.join(self.cfg.ckpt_dir, 'images', f'{epoch}_{act}_{t}.png'))
        total_loss[act_idx] /= count
        for (fidx, frame) in enumerate(frame_ids):
            self.summary.add_scalar(f'Test/{act}/{frame}', total_loss[act_idx][fidx], epoch)
    self.summary.add_scalar('Test/average', np.mean(total_loss), epoch)
    for (fidx, frame) in enumerate(frame_ids):
        self.summary.add_scalar(f'Test/avg{frame}', np.mean(total_loss[:, fidx]), epoch)
    return total_loss