class_docstr: Class performing adversarial training following Oracle Aligned Adversarial Training (OAAT) protocol.
  
  | Paper link: https://link.springer.com/chapter/10.1007/978-3-031-20065-6_18
class_docstr_tok: ["Class","performing","adversarial","training","following","Oracle","Aligned","Adversarial","Training","(","OAAT",")","protocol",".","|","Paper","link",":","https",":","\/\/link.springer.com\/chapter\/10.1007\/978-3-031-20065-6_18"]
docstr: Return the LPIPS distance between input_1 and input_2. `layers` is a list of either layer indices (between 0 and
  `nb_layers - 1`) or layers' name. The number of layers can be determined by counting the results returned by
  calling `layer_names`.
  
  :param p_classifier: model for adversarial training protocol.
  :param input_1: Input for computing the activations.
  :param input_2: Input for computing the activations.
  :param layers: Layers for computing the activations.
  :return: The lpips distance, where the first dimension is the batch size corresponding to
          `input_1`.
docstr_tok: ["Return","the","LPIPS","distance","between","input_1","and","input_2",".","`","layers","`","is","a","list","of","either","layer","indices","(","between","0","and","`","nb_layers","-","1","`",")","or","layers","'","name",".","The","number","of","layers","can","be","determined","by","counting","the","results","returned","by","calling","`","layer_names","`",".",":","param","p_classifier",":","model","for","adversarial","training","protocol",".",":","param","input_1",":","Input","for","computing","the","activations",".",":","param","input_2",":","Input","for","computing","the","activations",".",":","param","layers",":","Layers","for","computing","the","activations",".",":","return",":","The","lpips","distance",",","where","the","first","dimension","is","the","batch","size","corresponding","to","`","input_1","`","."]
code: def calculate_lpips_distance(  # type: ignore
      p_classifier: PyTorchClassifier,
      input_1: "torch.Tensor",
      input_2: "torch.Tensor",
      layers: List[Union[int, str]],
  ) -> "torch.Tensor":
      """
      Return the LPIPS distance between input_1 and input_2. `layers` is a list of either layer indices (between 0 and
      `nb_layers - 1`) or layers' name. The number of layers can be determined by counting the results returned by
      calling `layer_names`.
  
      :param p_classifier: model for adversarial training protocol.
      :param input_1: Input for computing the activations.
      :param input_2: Input for computing the activations.
      :param layers: Layers for computing the activations.
      :return: The lpips distance, where the first dimension is the batch size corresponding to
              `input_1`.
      """
  
      import torch
  
      (
          activations_input_1,
          list_layer_names,
      ) = AdversarialTrainerOAATPyTorch.get_layer_activations(
          p_classifier, input_1, layers
      )
      (
          activations_input_2,
          _,
      ) = AdversarialTrainerOAATPyTorch.get_layer_activations(
          p_classifier, input_2, layers
      )
      normalised_activations_1 = AdversarialTrainerOAATPyTorch.normalize_concatenate_activations(
          activations_input_1, list_layer_names
      )
      normalised_activations_2 = AdversarialTrainerOAATPyTorch.normalize_concatenate_activations(
          activations_input_2, list_layer_names
      )
      lpips_distance = torch.norm(
          normalised_activations_1 - normalised_activations_2, dim=1
      )
  
      return lpips_distance
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from collections import OrderedDict
  import logging
  import os
  import time
  from typing import Optional, Tuple, TYPE_CHECKING, List, Dict, Union
  import six
  import numpy
  from tqdm.auto import trange
  from art import config
  from art.defences.trainer.adversarial_trainer_oaat import AdversarialTrainerOAAT
  from art.estimators.classification.pytorch import PyTorchClassifier
  from art.data_generators import DataGenerator
  from art.attacks.attack import EvasionAttack
  from art.utils import check_and_transform_label_format, random_sphere
  from art.config import ART_NUMPY_DTYPE
label_desc: Use image node_id 10 for calling the AdversarialTrainerOAATPyTorch obj's underlying member method code with example usage: obj.calculate_lpips_distance(p_classifier, input_1, input_2, layers) and returns: lpips_distance