# 训练多个 epoch
    for epoch in range(args.max_epoch):
        running_loss = 0.0
    
        # 在每个 epoch 中迭代训练数据
        for images, labels in train_loader:
            print (f'images is {images}')
            print (f'labels is {labels}')
            # images = torch.tensor(images)
            images = images.to(device)
            category_ids = [label['category_id'] for label in labels]
            category_id = category_ids[0]
            category_ids_tensor = torch.tensor(category_id)
            category_ids_tensor = category_ids_tensor.to(device)
            # labels = torch.tensor([label for label in labels])
            # labels = labels.to(device)
            # # 从字典中提取实数值并转换为列表
            # label_values = list(labels.values())

            # # 将列表转换为张量
            # labels_tensor = torch.Tensor(label_values)

            # # 然后根据需要将 labels_tensor 移动到设备上
            # labels_tensor = labels_tensor.to(device)
        
            # 清零梯度
            optimizer.zero_grad()
        
            # 前向传播
            outputs = model(images)
            output_tensor = outputs[0]
            outputs_tensor = torch.tensor(output_tensor)
            loss = criterion(outputs_tensor, category_ids_tensor)
        
            # 反向传播和优化
            loss.backward()
            optimizer.step()
        
            # 计算损失函数的平均值
            running_loss += loss.item() * images.size(0)
    
        epoch_loss = running_loss / len(dataset_train)
        print(f"Epoch {epoch+1}/{args.max_epoch} - Loss: {epoch_loss:.4f}")  帮我检查一下代码