docstr: Computes the first part (y-loss) of the loss function.
docstr_tok: ["Computes","the","first","part","(","y-loss",")","of","the","loss","function","."]
code: def compute_yloss(self, method):
      """Computes the first part (y-loss) of the loss function."""
      yloss = 0.0
      for i in range(self.total_CFs):
          if method == "l2_loss":
              temp_loss = tf.square(
                  tf.subtract(
                      self.model.get_output(self.cfs_frozen[i]),
                      self.target_cf,
                  )
              )
              temp_loss = temp_loss[:, (self.num_output_nodes - 1) :][
                  0
              ][0]
          elif method == "log_loss":
              temp_logits = tf.log(
                  tf.divide(
                      tf.abs(
                          tf.subtract(
                              self.model.get_output(self.cfs_frozen[i]),
                              0.000001,
                          )
                      ),
                      tf.subtract(
                          1.0,
                          tf.abs(
                              tf.subtract(
                                  self.model.get_output(
                                      self.cfs_frozen[i]
                                  ),
                                  0.000001,
                              )
                          ),
                      ),
                  )
              )
              temp_logits = temp_logits[
                  :, (self.num_output_nodes - 1) :
              ]
              temp_loss = tf.nn.sigmoid_cross_entropy_with_logits(
                  logits=temp_logits, labels=self.target_cf
              )[0][0]
          elif method == "hinge_loss":
              temp_logits = tf.log(
                  tf.divide(
                      tf.abs(
                          tf.subtract(
                              self.model.get_output(self.cfs_frozen[i]),
                              0.000001,
                          )
                      ),
                      tf.subtract(
                          1.0,
                          tf.abs(
                              tf.subtract(
                                  self.model.get_output(
                                      self.cfs_frozen[i]
                                  ),
                                  0.000001,
                              )
                          ),
                      ),
                  )
              )
              temp_logits = temp_logits[
                  :, (self.num_output_nodes - 1) :
              ]
              temp_loss = tf.losses.hinge_loss(
                  logits=temp_logits, labels=self.target_cf
              )
  
          yloss = tf.add(yloss, temp_loss)
  
      return tf.divide(yloss, tf.cast(self.total_CFs, dtype=tf.float32))
  
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 6 for calling the DiceTensorFlow1 obj's underlying member method code with example usage: obj.compute_yloss(method) and returns: tf