class_docstr: Implementation of the composite adversarial attack on image classifiers in PyTorch. The attack is constructed by
  adversarially perturbing the hue component of the inputs. It uses order scheduling to search for the attack sequence
  and uses the iterative gradient sign method to optimize the perturbations in semantic space and Lp-ball (see
  `FastGradientMethod` and `BasicIterativeMethod`).
  
  | Note that this attack is intended for only PyTorch image classifiers with RGB images in the range [0, 1] as inputs
  
  | Paper link: https://arxiv.org/abs/2202.04235
class_docstr_tok: ["Implementation","of","the","composite","adversarial","attack","on","image","classifiers","in","PyTorch",".","The","attack","is","constructed","by","adversarially","perturbing","the","hue","component","of","the","inputs",".","It","uses","order","scheduling","to","search","for","the","attack","sequence","and","uses","the","iterative","gradient","sign","method","to","optimize","the","perturbations","in","semantic","space","and","Lp-ball","(","see","`","FastGradientMethod","`","and","`","BasicIterativeMethod","`",")",".","|","Note","that","this","attack","is","intended","for","only","PyTorch","image","classifiers","with","RGB","images","in","the","range","[","0",",","1","]","as","inputs","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2202.04235"]
docstr: Compute the adversarial examples for each attack component.
  
  :param data: A tensor of a batch of original inputs to be attacked.
  :param labels: A tensor of a batch of the original labels to be predicted.
  :param attack_idx: The index of the attack component (one of the enabled attacks) in the attack pool.
  :param attack_parameter: Specify the parameter of the attack component. For example, hue shift angle, saturation
   factor, etc.
  :param ori_is_attacked: Specify whether the perturbed data is already attacked.
  :return: The perturbed data and the corresponding attack parameter.
docstr_tok: ["Compute","the","adversarial","examples","for","each","attack","component",".",":","param","data",":","A","tensor","of","a","batch","of","original","inputs","to","be","attacked",".",":","param","labels",":","A","tensor","of","a","batch","of","the","original","labels","to","be","predicted",".",":","param","attack_idx",":","The","index","of","the","attack","component","(","one","of","the","enabled","attacks",")","in","the","attack","pool",".",":","param","attack_parameter",":","Specify","the","parameter","of","the","attack","component",".","For","example",",","hue","shift","angle",",","saturation","factor",",","etc",".",":","param","ori_is_attacked",":","Specify","whether","the","perturbed","data","is","already","attacked",".",":","return",":","The","perturbed","data","and","the","corresponding","attack","parameter","."]
code: def _comp_pgd(
      self,
      data: "torch.Tensor",
      labels: "torch.Tensor",
      attack_idx: int,
      attack_parameter: "torch.Tensor",
      ori_is_attacked: "torch.Tensor",
  ) -> Tuple["torch.Tensor", "torch.Tensor"]:
      """
      Compute the adversarial examples for each attack component.
  
      :param data: A tensor of a batch of original inputs to be attacked.
      :param labels: A tensor of a batch of the original labels to be predicted.
      :param attack_idx: The index of the attack component (one of the enabled attacks) in the attack pool.
      :param attack_parameter: Specify the parameter of the attack component. For example, hue shift angle, saturation
       factor, etc.
      :param ori_is_attacked: Specify whether the perturbed data is already attacked.
      :return: The perturbed data and the corresponding attack parameter.
      """
      import torch
      import torch.nn.functional as F
  
      adv_data = self.attack_pool_base[attack_idx](
          data, attack_parameter
      )
      for _ in range(self.max_inner_iter):
          outputs = self.model(adv_data)
  
          if not self._is_scheduling and self.early_stop:
              cur_pred = outputs.max(1, keepdim=True)[1].squeeze()
              self.is_attacked = torch.logical_or(
                  ori_is_attacked,
                  cur_pred != labels.max(1, keepdim=True)[1].squeeze(),
              )
  
          with torch.enable_grad():
              cost = F.cross_entropy(outputs, labels)
          _grad = torch.autograd.grad(cost, attack_parameter)[0]
          if not self._is_scheduling:
              _grad[self.is_attacked] = 0
          attack_parameter = (
              torch.clamp(
                  attack_parameter
                  + torch.sign(_grad) * self.step_size_pool[attack_idx],
                  self.eps_pool[attack_idx][0],
                  self.eps_pool[attack_idx][1],
              )
              .detach()
              .requires_grad_()
          )
          adv_data = self.attack_pool_base[attack_idx](
              data, attack_parameter
          )
  
      return adv_data, attack_parameter
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, List, TYPE_CHECKING
  import numpy
  from tqdm.auto import tqdm
  from art.attacks.attack import EvasionAttack
  from art.config import ART_NUMPY_DTYPE
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import compute_success, check_and_transform_label_format
label_desc: Use image node_id 6 for calling the CompositeAdversarialAttackPyTorch obj's underlying member method code with example usage: obj._comp_pgd(data, labels, attack_idx, attack_parameter, ori_is_attacked) and returns: adv_data,  attack_parameter