docstr: Computes the third part (diversity) of the loss function.
docstr_tok: ["Computes","the","third","part","(","diversity",")","of","the","loss","function","."]
code: def compute_diversity_loss(self, method):
      """Computes the third part (diversity) of the loss function."""
      if self.total_CFs == 1:
          return tf.constant(0.0)
  
      if "dpp" in method:
          submethod = method.split(":")[1]
          return tf.reduce_sum(self.dpp_style(submethod))
      elif method == "avg_dist":
          diversity_loss = 0.0
          count = 0.0
          # computing pairwise distance and transforming it to normalized similarity
          for i in range(self.total_CFs):
              for j in range(i + 1, self.total_CFs):
                  count += 1.0
                  diversity_loss = tf.add(
                      diversity_loss,
                      tf.divide(
                          1.0,
                          tf.add(
                              1.0,
                              self.compute_dist(
                                  self.cfs_frozen[i], self.cfs_frozen[j]
                              ),
                          ),
                      ),
                  )
          return tf.subtract(1.0, tf.divide(diversity_loss, count))
  
imports: import collections
  import copy
  import random
  import timeit
  import numpy
  import tensorflow
  from dice_ml import diverse_counterfactuals
  from dice_ml.counterfactual_explanations import CounterfactualExplanations
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
label_desc: Use image node_id 10 for calling the DiceTensorFlow1 obj's underlying member method code with example usage: obj.compute_diversity_loss(method) and returns: tf, tf, tf