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):
      """Computes the third part (diversity) of the loss function."""
      if self.total_CFs == 1:
          return tf.constant(0.0)
  
      if "dpp" in self.diversity_loss_type:
          submethod = self.diversity_loss_type.split(":")[1]
          return tf.reduce_sum(self.dpp_style(submethod))
      elif self.diversity_loss_type == "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 += 1.0 / (
                      1.0 + self.compute_dist(self.cfs[i], self.cfs[j])
                  )
  
          return 1.0 - (diversity_loss / count)
  
imports: 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 13 for calling the DiceTensorFlow2 obj's underlying member method code with example usage: obj.compute_diversity_loss() and returns: tf, tf, unknown