code: def test_append_attack(
      art_warning, fix_get_synthetic_data, fix_make_dummy_model
  ):
      """
      Check append attack wih a given l0 budget
      """
      try:
          param_dic = {
              "maxlen": 2**20,
              "input_dim": 257,
              "embedding_size": 8,
          }
          l0_budget = 1250
          attack = MalwareGDTensorFlow(
              classifier=fix_make_dummy_model[0],
              embedding_weights=fix_make_dummy_model[1],
              l_0=l0_budget,
              param_dic=param_dic,
          )
  
          x = np.copy(fix_get_synthetic_data[0])
          y = np.copy(fix_get_synthetic_data[1])
          size_of_files = np.copy(fix_get_synthetic_data[2])
  
          adv_x, adv_y, adv_sizes = attack.pull_out_valid_samples(
              x, y, size_of_files
          )
  
          # We should only have 2 files as the following cannot be converted to valid adv samples:
          #   2nd datapoint (file too large to support any modifications)
          #   4th datapoint (file to large to support append attacks)
          #   5th datapoint (benign file)
  
          assert len(adv_x) == 2
  
          adv_x = attack.generate(adv_x, adv_y, adv_sizes)
  
          j = 0
          for i, size in enumerate(fix_get_synthetic_data[2]):
              if i in [0, 2]:
                  assert np.array_equal(
                      adv_x[j, :size],
                      fix_get_synthetic_data[0][i, :size],
                  )
                  assert not np.array_equal(
                      adv_x[j, size : size + l0_budget],
                      fix_get_synthetic_data[0][
                          i, size : size + l0_budget
                      ],
                  )
                  assert np.array_equal(
                      adv_x[j, size + l0_budget :],
                      fix_get_synthetic_data[0][i, size + l0_budget :],
                  )
                  j += 1
              else:
                  assert np.array_equal(
                      x[i], fix_get_synthetic_data[0][i]
                  )
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/evasion/test_pe_malware_attack.py
imports: import pytest
  import tensorflow
  import numpy
  from tests.attacks.utils import backend_test_classifier_type_check_fail
  from art.attacks.evasion.pe_malware_attack import MalwareGDTensorFlow
  from art.estimators.classification import TensorFlowV2Classifier
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from tests.utils import ARTTestException
label_desc: Use image node_id 4 for calling a global function with example usage: test_append_attack(art_warning, fix_get_synthetic_data, fix_make_dummy_model) without return types