class_docstr: Class implementation of backdoor-based RED poisoning attack on DGM.
  
  | Paper link: https://arxiv.org/abs/2108.01644
class_docstr_tok: ["Class","implementation","of","backdoor-based","RED","poisoning","attack","on","DGM",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2108.01644"]
docstr: Calculates the fidelity of the poisoned model's target sample w.r.t. the original x_target sample
  :param z_trigger: the secret backdoor trigger that will produce the target
  :param x_target: the target to produce when using the trigger
docstr_tok: ["Calculates","the","fidelity","of","the","poisoned","model","'s","target","sample","w.r.t",".","the","original","x_target","sample",":","param","z_trigger",":","the","secret","backdoor","trigger","that","will","produce","the","target",":","param","x_target",":","the","target","to","produce","when","using","the","trigger"]
code: def fidelity(self, z_trigger: np.ndarray, x_target: np.ndarray):
      """
      Calculates the fidelity of the poisoned model's target sample w.r.t. the original x_target sample
      :param z_trigger: the secret backdoor trigger that will produce the target
      :param x_target: the target to produce when using the trigger
      """
      import tensorflow as tf
  
      return tf.reduce_mean(
          tf.math.squared_difference(
              tf.dtypes.cast(
                  self.estimator.predict(z_trigger), tf.float64
              ),
              tf.dtypes.cast(x_target, tf.float64),
          )
      )
  
file_path: adversarial-robustness-toolbox/art/attacks/poisoning/backdoor_attack_dgm/backdoor_attack_dgm_red.py
imports: import logging
  from typing import TYPE_CHECKING
  import numpy
  from art.attacks.attack import PoisoningAttackGenerator
  from art.estimators.generation.tensorflow import TensorFlowV2Generator
label_desc: Use image node_id 2 for calling the BackdoorAttackDGMReDTensorFlowV2 obj's underlying member method code with example usage: obj.fidelity(z_trigger, x_target) and returns: tf