class_docstr: Implementation of the following white-box attacks related to PE malware crafting:
      1) Append based attacks (example paper link: https://arxiv.org/abs/1810.08280)
      2) Section insertion attacks (example paper link: https://arxiv.org/abs/2008.07125)
      3) Slack manipulation attacks (example paper link: https://arxiv.org/abs/1810.08280)
      4) DOS Header Attacks (example paper link: https://arxiv.org/abs/1901.03583)
class_docstr_tok: ["Implementation","of","the","following","white-box","attacks","related","to","PE","malware","crafting",":","1",")","Append","based","attacks","(","example","paper","link",":","https",":","\/\/arxiv.org\/abs\/1810.08280",")","2",")","Section","insertion","attacks","(","example","paper","link",":","https",":","\/\/arxiv.org\/abs\/2008.07125",")","3",")","Slack","manipulation","attacks","(","example","paper","link",":","https",":","\/\/arxiv.org\/abs\/1810.08280",")","4",")","DOS","Header","Attacks","(","example","paper","link",":","https",":","\/\/arxiv.org\/abs\/1901.03583",")"]
docstr: Checks that we can append the l0 perturbation to the malware sample and not exceed the
  maximum file size. A new label vector with just the valid files indicated is created.
  
  :param y: Labels.
  :param sample_sizes: The size of the original file, before it was padded to the input size required by MalConv.
  :param append_perturbation_size: Size of the perturbations in L0 terms to put at end of file.
  :return adv_label_vector: Labels which indicate which malware samples have enough free features to
                            accommodate all the adversarial perturbation.
docstr_tok: ["Checks","that","we","can","append","the","l0","perturbation","to","the","malware","sample","and","not","exceed","the","maximum","file","size",".","A","new","label","vector","with","just","the","valid","files","indicated","is","created",".",":","param","y",":","Labels",".",":","param","sample_sizes",":","The","size","of","the","original","file",",","before","it","was","padded","to","the","input","size","required","by","MalConv",".",":","param","append_perturbation_size",":","Size","of","the","perturbations","in","L0","terms","to","put","at","end","of","file",".",":","return","adv_label_vector",":","Labels","which","indicate","which","malware","samples","have","enough","free","features","to","accommodate","all","the","adversarial","perturbation","."]
code: def check_valid_size(
      self,
      y: np.ndarray,
      sample_sizes: np.ndarray,
      append_perturbation_size: np.ndarray,
  ) -> np.ndarray:
      """
      Checks that we can append the l0 perturbation to the malware sample and not exceed the
      maximum file size. A new label vector with just the valid files indicated is created.
  
      :param y: Labels.
      :param sample_sizes: The size of the original file, before it was padded to the input size required by MalConv.
      :param append_perturbation_size: Size of the perturbations in L0 terms to put at end of file.
      :return adv_label_vector: Labels which indicate which malware samples have enough free features to
                                accommodate all the adversarial perturbation.
      """
  
      adv_label_vector = np.zeros_like(y)
      for i, label in enumerate(y):
          if label == 1:
              if (
                  sample_sizes[i] + append_perturbation_size[i]
                  <= self.param_dic["maxlen"]
              ):
                  adv_label_vector[i] = 1
                  logger.info(
                      "size to append on sample %d is %d",
                      i,
                      append_perturbation_size[i],
                  )
  
      return adv_label_vector
  
imports: import json
  import random
  import logging
  from typing import Optional, Union, Tuple, List, Dict, TYPE_CHECKING
  from tqdm.auto import trange
  import numpy
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.attacks.attack import EvasionAttack
label_desc: Use image node_id 4 for calling the MalwareGDTensorFlow obj's underlying member method code with example usage: obj.check_valid_size(y, sample_sizes, append_perturbation_size) and returns: adv_label_vector