Following 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 : 
i want defences also like attack struture 
#defence.py
from .defences import (
    EvasionDetector,
    BinaryInputDetector,
    BinaryActivationDetector,
    SubsetScanningDetector,
    PoisonFilteringDefence,
    GroundTruthEvaluator,
    ActivationDefence,
    ClusteringAnalyzer,
    ProvenanceDefense,
    RONIDefense,
    SpectralSignatureDefense,
    ClassLabels,
    GaussianNoise,
    HighConfidence,
    Postprocessor,
    ReverseSigmoid,
    Rounded,
    CutMix,
    CutMixPyTorch,
    CutMixTensorFlowV2,
    Cutout,
    CutoutPyTorch,
    CutoutTensorFlowV2,
    FeatureSqueezing,
    GaussianAugmentation,
    DefenseGAN,
    InverseGAN,
    JpegCompression,
    LabelSmoothing,
    Mixup,
    MixupPyTorch,
    MixupTensorFlowV2,
    Mp3Compression,
    Mp3CompressionPyTorch,
    PixelDefend,
    Preprocessor,
    Resample,
    SpatialSmoothing,
    SpatialSmoothingPyTorch,
    SpatialSmoothingTensorFlowV2,
    ThermometerEncoding,
    TotalVarMin,
    VideoCompression,
    VideoCompressionPyTorch,
    Trainer,
    AdversarialTrainer,
    AdversarialTrainerCertifiedPytorch,
    AdversarialTrainerCertifiedIBPPyTorch,
    AdversarialTrainerMadryPGD,
    AdversarialTrainerFBF,
    AdversarialTrainerFBFPyTorch,
    AdversarialTrainerTRADES,
    AdversarialTrainerTRADESPyTorch,
    AdversarialTrainerAWP,
    AdversarialTrainerAWPPyTorch,
    AdversarialTrainerOAAT,
    AdversarialTrainerOAATPyTorch,
    DPInstaHideTrainer,
    Transformer,
    evasion,
    poisoning
)

# List of defenses using ART module
def get_defense_list() -> List:
    try:
        # Define clip_values for images (min and max pixel values)
        clip_values = (0.0, 1.0)  # Adjust depending on image preprocessing, e.g., (0, 255) if not normalized

        defense_list = [
            JpegCompression(clip_values=clip_values, quality=50),
            FeatureSqueezing(bit_depth=1, clip_values=clip_values),
        ]
        return defense_list
    except Exception as e:
        print(f"Error creating defense list: {e}")
        raise



AttackType = Type[Any]  # Define a generic type for attacks


def get_attack_parameters(attack: AttackType) -> Dict[str, Any]:
    """Retrieve default parameters for each attack.

    Args:
        attack (AttackType): The attack class.

    Returns:
        Dict[str, Any]: Dictionary of parameters.
    """
    # Define default parameters for each attack
    default_params: Dict[Type[Any], Dict[str, Any]] = {
        # 1) AdversarialPatch
        AdversarialPatch: {
               "rotation_max": 22.5,
               "scale_min":  0.1,
               "scale_max": 1.0,
               "learning_rate":5.0,
               "max_iter":  500,
               "batch_size": 16,
               "patch_shape": (3, 10, 10),
               "targeted":True,
               "verbose": True,
        },



def get_all_attacks() -> List[AttackType]:
    """Retrieve all attack classes to be tested.

    Returns:
        List[AttackType]: List of attack classes.
    """
    return [
        AdversarialPatch,
        AdversarialPatchNumpy,
        AdversarialPatchPyTorch,
        AdversarialTexturePyTorch, 
        AutoAttack,
        AutoProjectedGradientDescent,
        AutoConjugateGradient,
        BrendelBethgeAttack,
        BoundaryAttack, # done
        CompositeAdversarialAttackPyTorch,
        CarliniL2Method,
        CarliniLInfMethod,
        # CarliniL0Method, #*
        DeepFool,
        DPatch, # note object detection
        RobustDPatch, # note object detection
        ElasticNet,
        FastGradientMethod,
        # FrameSaliencyAttack, # *
        # FeatureAdversariesPyTorch, # *
        GeoDA,
        # GRAPHITEBlackbox, # *
        GRAPHITEWhiteboxPyTorch,
        # HighConfidenceLowUncertainty, # *
        HopSkipJump,
        BasicIterativeMethod,
        # LaserAttack, #*
        # LowProFool, # *
        MomentumIterativeMethod,
        NewtonFool,
        OverloadPyTorch,
        PixelAttack,
        ProjectedGradientDescent,
        ProjectedGradientDescentPyTorch,
        # OverTheAirFlickeringPyTorch, # *
        SaliencyMapMethod,
        ShadowAttack,
        # ShapeShifter, # *
        # SimBA, # *
        SpatialTransformation,
        SquareAttack,
        # ThresholdAttack, #*
        UniversalPerturbation,
        # TargetedUniversalPerturbation, #*
        VirtualAdversarialMethod,
        Wasserstein,
        ZooAttack,
        SignOPTAttack,
    ]