ollowing this instruction :
1. Strictly adhere to PEP-8 standards, ensuring code is clean, well-structured, and follows Python's style guide for readability.
2. Use appropriate modules like `typing` for type hints, ensuring code clarity, maintainability, and leveraging Python's standard libraries effectively.
3. Focus on time, space, robustness, scalability; write optimized, efficient code that can handle large datasets and scale seamlessly.
4. Implement comprehensive error handling, catching exceptions gracefully, providing meaningful error messages, and ensuring code robustness under unexpected conditions.
5. Ensure the developer agent writes advanced, maintainable Python code, balancing performance and readability while adhering to best practices.




TASK : below bring simple api like below str, x, y control all attacks  


all below api should fixing call below 
def apply_attack(
    attack_class: AttackType,
    classifier: PyTorchClassifier, or estimers can required 
    inputs: np.ndarray,
    labels: np.ndarray,
) -> None:
    """Test a single adversarial attack.

    Args:
        attack_class (AttackType): The attack class to test.
        classifier (PyTorchClassifier): The classifier to attack.
        inputs (np.ndarray): Input data.
        labels (np.ndarray): True labels.
    """
    attack_name = attack_class.__name__
    logger.info(f"Testing attack: {attack_name}")

    try:
        params = get_attack_parameters(attack_class)

        # Handle special parameters if necessary
        if attack_name in ["AutoAttack"]:
            # Specifically set the estimator_orig parameter if required
            params["estimator_orig"] = classifier

        attack = attack_class(classifier, **params)
        adversarial_examples = attack.generate(x=inputs, y=labels)
        logger.info(f"{attack_name} performed successfully.")

        # Check if adversarial examples are generated
    except NotImplementedError:
        logger.warning(f"{attack_name} is not implemented for PyTorchClassifier.")
    except TypeError as te:
        logger.error(
            f"Type error while initializing {attack_name}: {te}. Check parameter compatibility."
        )
    except Exception as e:
        logger.error(f"Error performing {attack_name}: {e}")



parameters 


{'AdversarialPatch': {'classifier': None, 'rotation_max': 22.5, 'scale_min': 0.1, 'scale_max': 1.0, 'learning_rate': 5.0, 'max_iter': 500, 'batch_size': 16, 'patch_shape': None, 'targeted': True, 'verbose': True}, 'AdversarialPatchNumpy': {'classifier': None, 'target': 0, 'rotation_max': 22.5, 'scale_min': 0.1, 'scale_max': 1.0, 'learning_rate': 5.0, 'max_iter': 500, 'clip_patch': None, 'batch_size': 16, 'targeted': True, 'verbose': True}, 'AdversarialPatchTensorFlowV2': {'classifier': None, 'rotation_max': 22.5, 'scale_min': 0.1, 'scale_max': 1.0, 'learning_rate': 5.0, 'max_iter': 500, 'batch_size': 16, 'patch_shape': None, 'optimizer': 'Adam', 'targeted': True, 'summary_writer': False, 'verbose': True}, 'AdversarialPatchPyTorch': {'estimator': None, 'rotation_max': 22.5, 'scale_min': 0.1, 'scale_max': 1.0, 'distortion_scale_max': 0.0, 'learning_rate': 5.0, 'max_iter': 500, 'batch_size': 16, 'patch_shape': (3, 224, 224), 'patch_location': None, 'patch_type': 'circle', 'optimizer': 'Adam', 'targeted': True, 'summary_writer': False, 'verbose': True}, 'AdversarialTexturePyTorch': {'estimator': None, 'patch_height': None, 'patch_width': None, 'x_min': 0, 'y_min': 0, 'step_size': 0.00392156862745098, 'max_iter': 500, 'batch_size': 16, 'summary_writer': False, 'verbose': True}, 'CarliniWagnerASR': {'estimator': None, 'eps': 2000.0, 'learning_rate': 100.0, 'max_iter': 1000, 'decrease_factor_eps': 0.8, 'num_iter_decrease_eps': 10, 'batch_size': 16}, 'AutoAttack': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'attacks': None, 'batch_size': 32, 'estimator_orig': None, 'targeted': False, 'parallel': False}, 'AutoProjectedGradientDescent': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'max_iter': 100, 'targeted': False, 'nb_random_init': 5, 'batch_size': 32, 'loss_type': None, 'verbose': True}, 'AutoConjugateGradient': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'max_iter': 100, 'targeted': False, 'nb_random_init': 5, 'batch_size': 32, 'loss_type': None, 'verbose': True}, 'BrendelBethgeAttack': {'estimator': None, 'norm': inf, 'targeted': False, 'overshoot': 1.1, 'steps': 10, 'lr': 0.001, 'lr_decay': 0.5, 'lr_num_decay': 20, 'momentum': 0.8, 'binary_search_steps': 10, 'init_size': 100, 'batch_size': 32}, 'BoundaryAttack': {'estimator': None, 'batch_size': 64, 'targeted': True, 'delta': 0.01, 'epsilon': 0.01, 'step_adapt': 0.667, 'max_iter': 5000, 'num_trial': 25, 'sample_size': 20, 'init_size': 100, 'min_epsilon': 0.0, 'verbose': True}, 'CompositeAdversarialAttackPyTorch': {'classifier': None, 'enabled_attack': (0, 1, 2, 3, 4, 5), 'hue_epsilon': (-3.141592653589793, 3.141592653589793), 'sat_epsilon': (0.7, 1.3), 'rot_epsilon': (-10.0, 10.0), 'bri_epsilon': (-0.2, 0.2), 'con_epsilon': (0.7, 1.3), 'pgd_epsilon': (-0.03137254901960784, 0.03137254901960784), 'early_stop': True, 'max_iter': 5, 'max_inner_iter': 10, 'attack_order': 'scheduled', 'batch_size': 1, 'verbose': True}, 'CarliniL2Method': {'classifier': None, 'confidence': 0.0, 'targeted': False, 'learning_rate': 0.01, 'binary_search_steps': 10, 'max_iter': 10, 'initial_const': 0.01, 'max_halving': 5, 'max_doubling': 5, 'batch_size': 1, 'verbose': True}, 'CarliniLInfMethod': {'classifier': None, 'confidence': 0.0, 'targeted': False, 'learning_rate': 0.01, 'max_iter': 10, 'decrease_factor': 0.9, 'initial_const': 1e-05, 'largest_const': 20.0, 'const_factor': 2.0, 'batch_size': 1, 'verbose': True}, 'CarliniL0Method': {'classifier': None, 'confidence': 0.0, 'targeted': False, 'learning_rate': 0.01, 'binary_search_steps': 10, 'max_iter': 10, 'initial_const': 0.01, 'mask': None, 'warm_start': True, 'max_halving': 5, 'max_doubling': 5, 'batch_size': 1, 'verbose': True}, 'DecisionTreeAttack': {'classifier': None, 'offset': 0.001, 'verbose': True}, 'DeepFool': {'classifier': None, 'max_iter': 100, 'epsilon': 1e-06, 'nb_grads': 10, 'batch_size': 1, 'verbose': True}, 'DPatch': {'estimator': None, 'patch_shape': (40, 40, 3), 'learning_rate': 5.0, 'max_iter': 500, 'batch_size': 16, 'verbose': True}, 'RobustDPatch': {'estimator': None, 'patch_shape': (40, 40, 3), 'patch_location': (0, 0), 'crop_range': (0, 0), 'brightness_range': (1.0, 1.0), 'rotation_weights': (1, 0, 0, 0), 'sample_size': 1, 'learning_rate': 5.0, 'max_iter': 500, 'batch_size': 16, 'targeted': False, 'summary_writer': False, 'verbose': True}, 'ElasticNet': {'classifier': None, 'confidence': 0.0, 'targeted': False, 'learning_rate': 0.01, 'binary_search_steps': 9, 'max_iter': 100, 'beta': 0.001, 'initial_const': 0.001, 'batch_size': 1, 'decision_rule': 'EN', 'verbose': True}, 'FastGradientMethod': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'targeted': False, 'num_random_init': 0, 'batch_size': 32, 'minimal': False, 'summary_writer': False}, 'FrameSaliencyAttack': {'classifier': None, 'attacker': None, 'method': 'iterative_saliency', 'frame_index': 1, 'batch_size': 1, 'verbose': True}, 'FeatureAdversariesNumpy': {'classifier': None, 'delta': None, 'layer': None, 'batch_size': 32}, 'FeatureAdversariesPyTorch': {'estimator': None, 'delta': None, 'optimizer': None, 'optimizer_kwargs': None, 'lambda_': 0.0, 'layer': -1, 'max_iter': 100, 'batch_size': 32, 'step_size': None, 'random_start': False, 'verbose': True}, 'FeatureAdversariesTensorFlowV2': {'estimator': None, 'delta': None, 'optimizer': None, 'optimizer_kwargs': None, 'lambda_': 0.0, 'layer': -1, 'max_iter': 100, 'batch_size': 32, 'step_size': None, 'random_start': False, 'verbose': True}, 'GeoDA': {'estimator': None, 'batch_size': 64, 'norm': 2, 'sub_dim': 10, 'max_iter': 4000, 'bin_search_tol': 0.1, 'lambda_param': 0.6, 'sigma': 0.0002, 'verbose': True}, 'GRAPHITEBlackbox': {'classifier': None, 'noise_size': None, 'net_size': None, 'heat_patch_size': (4, 4), 'heat_patch_stride': (1, 1), 'heatmap_mode': 'Target', 'tr_lo': 0.65, 'tr_hi': 0.85, 'num_xforms_mask': 100, 'max_mask_size': -1, 'beta': 1.0, 'eta': 500, 'num_xforms_boost': 100, 'num_boost_queries': 20000, 'rotation_range': (-30.0, 30.0), 'dist_range': (0.0, 0.0), 'gamma_range': (1.0, 2.0), 'crop_percent_range': (-0.03125, 0.03125), 'off_x_range': (-0.03125, 0.03125), 'off_y_range': (-0.03125, 0.03125), 'blur_kernels': (0, 3), 'batch_size': 64}, 'GRAPHITEWhiteboxPyTorch': {'classifier': None, 'net_size': None, 'min_tr': 0.8, 'num_xforms': 100, 'step_size': 0.0157, 'steps': 50, 'first_steps': 500, 'patch_removal_size': 4, 'patch_removal_interval': 2, 'num_patches_to_remove': 4, 'rand_start_epsilon_range': (-0.03137254901960784, 0.03137254901960784), 'rotation_range': (-30.0, 30.0), 'dist_range': (0.0, 0.0), 'gamma_range': (1.0, 2.0), 'crop_percent_range': (-0.03125, 0.03125), 'off_x_range': (-0.03125, 0.03125), 'off_y_range': (-0.03125, 0.03125), 'blur_kernels': (0, 3), 'batch_size': 64}, 'HighConfidenceLowUncertainty': {'classifier': None, 'conf': 0.95, 'unc_increase': 100.0, 'min_val': 0.0, 'max_val': 1.0, 'verbose': True}, 'HopSkipJump': {'classifier': None, 'batch_size': 64, 'targeted': False, 'norm': 2, 'max_iter': 50, 'max_eval': 10000, 'init_eval': 100, 'init_size': 100, 'verbose': True}, 'ImperceptibleASR': {'estimator': None, 'masker': None, 'eps': 2000.0, 'learning_rate_1': 100.0, 'max_iter_1': 1000, 'alpha': 0.05, 'learning_rate_2': 1.0, 'max_iter_2': 4000, 'loss_theta_min': 0.05, 'decrease_factor_eps': 0.8, 'num_iter_decrease_eps': 10, 'increase_factor_alpha': 1.2, 'num_iter_increase_alpha': 20, 'decrease_factor_alpha': 0.8, 'num_iter_decrease_alpha': 50, 'batch_size': 1}, 'ImperceptibleASRPyTorch': {'estimator': None, 'eps': 0.05, 'max_iter_1': 10, 'max_iter_2': 4000, 'learning_rate_1': 0.001, 'learning_rate_2': 0.0005, 'optimizer_1': None, 'optimizer_2': None, 'global_max_length': 200000, 'initial_rescale': 1.0, 'decrease_factor_eps': 0.8, 'num_iter_decrease_eps': 1, 'alpha': 1.2, 'increase_factor_alpha': 1.2, 'num_iter_increase_alpha': 20, 'decrease_factor_alpha': 0.8, 'num_iter_decrease_alpha': 20, 'win_length': 2048, 'hop_length': 512, 'n_fft': 2048, 'batch_size': 32, 'use_amp': False, 'opt_level': 'O1'}, 'BasicIterativeMethod': {'estimator': None, 'eps': 0.3, 'eps_step': 0.1, 'max_iter': 100, 'targeted': False, 'batch_size': 32, 'verbose': True}, 'LaserAttack': {'estimator': None, 'iterations': None, 'laser_generator': None, 'image_generator': <art.attacks.evasion.laser_attack.utils.ImageGenerator object at 0x0000023D93F08B60>, 'random_initializations': 1, 'optimisation_algorithm': <function greedy_search at 0x0000023D93EEB4C0>, 'debug': None}, 'LowProFool': {'classifier': None, 'n_steps': 100, 'threshold': 0.5, 'lambd': 1.5, 'eta': 0.2, 'eta_decay': 0.98, 'eta_min': 1e-07, 'norm': 2, 'importance': 'pearson', 'verbose': False}, 'MomentumIterativeMethod': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'decay': 1.0, 'max_iter': 100, 'targeted': False, 'batch_size': 32, 'verbose': True}, 'NewtonFool': {'classifier': None, 'max_iter': 100, 'eta': 0.01, 'batch_size': 1, 'verbose': True}, 'OverloadPyTorch': {'estimator': None, 'eps': None, 'max_iter': None, 'num_grid': None, 'batch_size': None}, 'MalwareGDTensorFlow': {'classifier': None, 'embedding_weights': None, 'param_dic': None, 'num_of_iterations': 10, 'l_0': 0.1, 'l_r': 1.0, 'use_sign': False, 'verbose': False}, 'PixelAttack': {'classifier': None, 'th': None, 'es': 1, 'max_iter': 100, 'targeted': False, 'verbose': False}, 'ProjectedGradientDescent': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'decay': None, 'max_iter': 100, 'targeted': False, 'num_random_init': 0, 'batch_size': 32, 'random_eps': False, 'summary_writer': False, 'verbose': True}, 'ProjectedGradientDescentNumpy': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'decay': None, 'max_iter': 100, 'targeted': False, 'num_random_init': 0, 'batch_size': 32, 'random_eps': False, 'summary_writer': False, 'verbose': True}, 'ProjectedGradientDescentPyTorch': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'decay': None, 'max_iter': 100, 'targeted': False, 'num_random_init': 0, 'batch_size': 32, 'random_eps': False, 'summary_writer': False, 'verbose': True}, 'ProjectedGradientDescentTensorFlowV2': {'estimator': None, 'norm': inf, 'eps': 0.3, 'eps_step': 0.1, 'decay': None, 'max_iter': 100, 'targeted': False, 'num_random_init': 0, 'batch_size': 32, 'random_eps': False, 'summary_writer': False, 'verbose': True}, 'OverTheAirFlickeringPyTorch': {'classifier': None, 'eps_step': 0.01, 'max_iter': 30, 'beta_0': 1.0, 'beta_1': 0.5, 'beta_2': 0.5, 'loss_margin': 0.05, 'batch_size': 1, 'start_frame_index': 0, 'num_frames': None, 'round_samples': 0.0, 'targeted': False, 'verbose': True}, 'SaliencyMapMethod': {'classifier': None, 'theta': 0.1, 'gamma': 1.0, 'batch_size': 1, 'verbose': True}, 'ShadowAttack': {'estimator': None, 'sigma': 0.5, 'nb_steps': 300, 'learning_rate': 0.1, 'lambda_tv': 0.3, 'lambda_c': 1.0, 'lambda_s': 0.5, 'batch_size': 400, 'targeted': False, 'verbose': True}, 'ShapeShifter': {'estimator': None, 'random_transform': None, 'box_classifier_weight': 1.0, 'box_localizer_weight': 2.0, 'rpn_classifier_weight': 1.0, 'rpn_localizer_weight': 2.0, 'box_iou_threshold': 0.5, 'box_victim_weight': 0.0, 'box_target_weight': 0.0, 'box_victim_cw_weight': 0.0, 'box_victim_cw_confidence': 0.0, 'box_target_cw_weight': 0.0, 'box_target_cw_confidence': 0.0, 'rpn_iou_threshold': 0.5, 'rpn_background_weight': 0.0, 'rpn_foreground_weight': 0.0, 'rpn_cw_weight': 0.0, 'rpn_cw_confidence': 0.0, 'similarity_weight': 0.0, 'learning_rate': 1.0, 'optimizer': 'GradientDescentOptimizer', 'momentum': 0.0, 'decay': 0.0, 'sign_gradients': False, 'random_size': 10, 'max_iter': 10, 'texture_as_input': False, 'use_spectral': True, 'soft_clip': False}, 'SimBA': {'classifier': None, 'attack': 'dct', 'max_iter': 3000, 'order': 'random', 'epsilon': 0.1, 'freq_dim': 4, 'stride': 1, 'targeted': False, 'batch_size': 1, 'verbose': True}, 'SpatialTransformation': {'classifier': None, 'max_translation': 0.0, 'num_translations': 1, 'max_rotation': 0.0, 'num_rotations': 1, 'verbose': True}, 'SquareAttack': {'estimator': None, 'norm': inf, 'adv_criterion': None, 'loss': None, 'max_iter': 100, 'eps': 0.3, 'p_init': 0.8, 'nb_restarts': 1, 'batch_size': 128, 'verbose': True}, 'ThresholdAttack': {'classifier': None, 'th': None, 'es': 0, 'max_iter': 100, 'targeted': False, 'verbose': False}, 'UniversalPerturbation': {'classifier': None, 'attacker': 'deepfool', 'attacker_params': None, 'delta': 0.2, 'max_iter': 20, 'eps': 10.0, 'norm': inf, 'batch_size': 32, 'verbose': True}, 'TargetedUniversalPerturbation': {'classifier': None, 'attacker': 'fgsm', 'attacker_params': None, 'delta': 0.2, 'max_iter': 20, 'eps': 10.0, 'norm': inf}, 'VirtualAdversarialMethod': {'classifier': None, 'max_iter': 10, 'finite_diff': 1e-06, 'eps': 0.1, 'batch_size': 1, 'verbose': True}, 'Wasserstein': {'estimator': None, 'targeted': False, 'regularization': 3000.0, 'p': 2, 'kernel_size': 5, 'eps_step': 0.1, 'norm': 'wasserstein', 'ball': 'wasserstein', 'eps': 0.3, 'eps_iter': 10, 'eps_factor': 1.1, 'max_iter': 400, 'conjugate_sinkhorn_max_iter': 400, 'projected_sinkhorn_max_iter': 400, 'batch_size': 1, 'verbose': True}, 'ZooAttack': {'classifier': None, 'confidence': 0.0, 'targeted': False, 'learning_rate': 0.01, 'max_iter': 10, 'binary_search_steps': 1, 'initial_const': 0.001, 'abort_early': True, 'use_resize': True, 'use_importance': True, 'nb_parallel': 128, 'batch_size': 1, 'variable_h': 0.0001, 'verbose': True}, 'SignOPTAttack': {'estimator': None, 'targeted': True, 'epsilon': 0.001, 'num_trial': 100, 'max_iter': 1000, 'query_limit': 20000, 'k': 200, 'alpha': 0.2, 'beta': 0.001, 'eval_perform': False, 'batch_size': 64, 'verbose': False}}




class EvasionAttack(Attack):
    """
    Abstract base class for evasion attack classes.
    """

    def __init__(self, **kwargs) -> None:
        self._targeted = False
        super().__init__(**kwargs)

    @abc.abstractmethod
    def generate(self, x: np.ndarray, y: np.ndarray | None = None, **kwargs) -> np.ndarray:
        """
        Generate adversarial examples and return them as an array. This method should be overridden by all concrete
        evasion attack implementations.

        :param x: An array with the original inputs to be attacked.
        :param y: Correct labels or target labels for `x`, depending on if the attack is targeted
                  or not. This parameter is only used by some of the attacks.
        :return: An array holding the adversarial examples.
        """
        raise NotImplementedError

    @property
    def targeted(self) -> bool:
        """
        Return Boolean if attack is targeted. Return None if not applicable.
        """
        return self._targeted

    @targeted.setter
    def targeted(self, targeted) -> None:
        self._targeted = targeted