class_docstr: Method from Chen et al., 2018 performing poisoning detection based on activations clustering.
  
  | Paper link: https://arxiv.org/abs/1811.03728
  
  | Please keep in mind the limitations of defences. For more information on the limitations of this
      defence, see https://arxiv.org/abs/1905.13409 . For details on how to evaluate classifier security
      in general, see https://arxiv.org/abs/1902.06705
docstr: Revert poison attack by continue training the current classifier with `x`, `y_fix`. `test_set_split` determines
  the percentage in x that will be used as training set, while `1-test_set_split` determines how many data points
  to use for test set.
  
  :param classifier: Classifier to be fixed.
  :param x: Samples.
  :param y_fix: True label of `x_poison`.
  :param test_set_split: this parameter determine how much data goes to the training set.
         Here `test_set_split*len(y_fix)` determines the number of data points in `x_train`
         and `(1-test_set_split) * len(y_fix)` the number of data points in `x_test`.
  :param tolerable_backdoor: Threshold that determines what is the maximum tolerable backdoor success rate.
  :param max_epochs: Maximum number of epochs that the model will be trained.
  :param batch_epochs: Number of epochs to be trained before checking current state of model.
  :return: (improve_factor, classifier).
docstr_tok: ["Revert","poison","attack","by","continue","training","the","current","classifier","with","`","x","`",",","`","y_fix","`",".","`","test_set_split","`","determines","the","percentage","in","x","that","will","be","used","as","training","set",",","while","`","1-test_set_split","`","determines","how","many","data","points","to","use","for","test","set",".",":","param","classifier",":","Classifier","to","be","fixed",".",":","param","x",":","Samples",".",":","param","y_fix",":","True","label","of","`","x_poison","`",".",":","param","test_set_split",":","this","parameter","determine","how","much","data","goes","to","the","training","set",".","Here","`","test_set_split","*","len","(","y_fix",")","`","determines","the","number","of","data","points","in","`","x_train","`","and","`","(","1-test_set_split",")","*","len","(","y_fix",")","`","the","number","of","data","points","in","`","x_test","`",".",":","param","tolerable_backdoor",":","Threshold","that","determines","what","is","the","maximum","tolerable","backdoor","success","rate",".",":","param","max_epochs",":","Maximum","number","of","epochs","that","the","model","will","be","trained",".",":","param","batch_epochs",":","Number","of","epochs","to","be","trained","before","checking","current","state","of","model",".",":","return",":","(","improve_factor",",","classifier",")","."]
code: def relabel_poison_ground_truth(
      classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
      x: np.ndarray,
      y_fix: np.ndarray,
      test_set_split: float = 0.7,
      tolerable_backdoor: float = 0.01,
      max_epochs: int = 50,
      batch_epochs: int = 10,
  ) -> Tuple[float, "CLASSIFIER_NEURALNETWORK_TYPE"]:
      """
      Revert poison attack by continue training the current classifier with `x`, `y_fix`. `test_set_split` determines
      the percentage in x that will be used as training set, while `1-test_set_split` determines how many data points
      to use for test set.
  
      :param classifier: Classifier to be fixed.
      :param x: Samples.
      :param y_fix: True label of `x_poison`.
      :param test_set_split: this parameter determine how much data goes to the training set.
             Here `test_set_split*len(y_fix)` determines the number of data points in `x_train`
             and `(1-test_set_split) * len(y_fix)` the number of data points in `x_test`.
      :param tolerable_backdoor: Threshold that determines what is the maximum tolerable backdoor success rate.
      :param max_epochs: Maximum number of epochs that the model will be trained.
      :param batch_epochs: Number of epochs to be trained before checking current state of model.
      :return: (improve_factor, classifier).
      """
      # Split data into testing and training:
      n_train = int(len(x) * test_set_split)
      x_train, x_test = x[:n_train], x[n_train:]
      y_train, y_test = y_fix[:n_train], y_fix[n_train:]
  
      filename = "original_classifier" + str(time.time()) + ".p"
      ActivationDefence._pickle_classifier(classifier, filename)
  
      # Now train using y_fix:
      improve_factor, _ = train_remove_backdoor(
          classifier,
          x_train,
          y_train,
          x_test,
          y_test,
          tolerable_backdoor=tolerable_backdoor,
          max_epochs=max_epochs,
          batch_epochs=batch_epochs,
      )
  
      # Only update classifier if there was an improvement:
      if improve_factor < 0:
          classifier = ActivationDefence._unpickle_classifier(filename)
          return 0, classifier
  
      ActivationDefence._remove_pickle(filename)
      return improve_factor, classifier
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import pickle
  import time
  from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
  import numpy
  from sklearn.cluster import KMeans, MiniBatchKMeans
  from art import config
  from art.data_generators import DataGenerator
  from art.defences.detector.poison.clustering_analyzer import ClusteringAnalyzer
  from art.defences.detector.poison.ground_truth_evaluator import GroundTruthEvaluator
  from art.defences.detector.poison.poison_filtering_defence import PoisonFilteringDefence
  from art.utils import segment_by_class
  from art.visualization import create_sprite, save_image, plot_3d
label_desc: Use image node_id 7 for calling the ActivationDefence obj's underlying member method code with example usage: obj.relabel_poison_ground_truth(classifier, x, y_fix, test_set_split, tolerable_backdoor, max_epochs, batch_epochs) and returns: improve_factor,  classifier, int,  classifier