text: """ Test case for Torch """
  from __future__ import absolute_import
  
  import torch
  import torchvision.models as models
  import numpy as np
  from perceptron.models.classification.pytorch import PyTorchModel
  from perceptron.utils.image import imagenet_example
  from perceptron.benchmarks.carlini_wagner import CarliniWagnerL2Metric
  from perceptron.utils.criteria.classification import Misclassification
  from perceptron.utils.tools import plot_image
  from perceptron.utils.tools import bcolors
  
  # instantiate the model
  resnet18 = models.resnet18(pretrained=True).eval()
  if torch.cuda.is_available():
      resnet18 = resnet18.cuda()
  
  # initialize the PyTorchModel
  mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1))
  std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1))
  fmodel = PyTorchModel(
      resnet18, bounds=(0, 1), num_classes=1000, preprocessing=(mean, std))
  
  # get source image and label
  image, label = imagenet_example(data_format='channels_first')
  image = image / 255.  # because our model expects values in [0, 1]
  
  
  metric = CarliniWagnerL2Metric(fmodel, criterion=Misclassification())
  
  
  print(bcolors.BOLD + 'Process start' + bcolors.ENDC)
  adversary = metric(image, label, unpack=False)
  print(bcolors.BOLD + 'Process finished' + bcolors.ENDC)
  
  if adversary.image is None:
      print(bcolors.WARNING + 'Warning: Cannot find an adversary!' + bcolors.ENDC)
      exit(-1)
  
  ###################  print summary info  #####################################
  keywords = ['PyTorch', 'Resent18', 'Misclassification', 'CarliniWagnerL2']
  
  true_label = np.argmax(fmodel.predictions(image))
  fake_label = np.argmax(fmodel.predictions(adversary.image))
  
  # interpret the label as human language
  with open('perceptron/utils/labels.txt') as info:
      imagenet_dict = eval(info.read())
  
  print(bcolors.HEADER + bcolors.UNDERLINE + 'Summary:' + bcolors.ENDC)
  print('Configuration:'  + bcolors.CYAN + ' --framework %s '
                                           '--model %s --criterion %s '
                                           '--metric %s' % tuple(keywords) + bcolors.ENDC)
  print('The predicted label of original image is '
        + bcolors.GREEN + imagenet_dict[true_label] + bcolors.ENDC)
  print('The predicted label of adversary image is '
        + bcolors.RED + imagenet_dict[fake_label] + bcolors.ENDC)
  print('Minimum perturbation required: %s' % bcolors.BLUE
        + str(adversary.distance) + bcolors.ENDC)
  print('\n')
  
  plot_image(adversary,
             title=', '.join(keywords),
             figname='examples/images/%s.png' % '_'.join(keywords))
  
  