text: import torch
  
  
  def train(model, train_loader, optimizer, criterion, DEVICE, epoch, log_interval):
  
      model.train()
      for batch_idx, (image, label) in enumerate(train_loader):
          image = image.to(DEVICE)
          label = label.to(DEVICE)
          optimizer.zero_grad()
          output = model(image)
          loss = criterion(output, label)
          loss.backward()
          optimizer.step()
  
          if batch_idx % log_interval == 0:
              print("Train Epoch: {} [{}/{} ({:.0f}%)]\tTrain Loss: {:.6f}".format(
                  epoch, batch_idx * len(image),
                  len(train_loader.dataset), 100. * batch_idx / len(train_loader),
                  loss.item()))
  
  
  def evaluate(model, test_loader, criterion, DEVICE):
      model.eval()
      test_loss = 0
      correct = 0
  
      with torch.no_grad():
          for image, label in test_loader:
              image = image.to(DEVICE)
              label = label.to(DEVICE)
              output = model(image)
              test_loss += criterion(output, label).item()
              prediction = output.max(1, keepdim=True)[1]
              correct += prediction.eq(label.view_as(prediction)).sum().item()
  
      test_loss /= len(test_loader.dataset)
      test_accuracy = 100. * correct / len(test_loader.dataset)
      return test_loss, test_accuracy
  
  
  def test(model, image, DEVICE):
  
      model.eval()
      with torch.no_grad():
          image = image.to(DEVICE)
          # label = label.to(DEVICE)
  
          outputs = model(image)
          _, predicted = torch.max(outputs, 1)
  
      return predicted
  