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, cfs, desired_range, desired_class):
      """Computes the first part (y-loss) of the loss function."""
      yloss = 0.0
      if self.model.model_type == ModelTypes.Classifier:
          predicted_value = np.array(self.predict_fn_scores(cfs))
          if self.yloss_type == "hinge_loss":
              maxvalue = np.full((len(predicted_value)), -np.inf)
              for c in range(self.num_output_nodes):
                  if c != desired_class:
                      maxvalue = np.maximum(
                          maxvalue, predicted_value[:, c]
                      )
              yloss = np.maximum(
                  0, maxvalue - predicted_value[:, int(desired_class)]
              )
          return yloss
  
      elif self.model.model_type == ModelTypes.Regressor:
          predicted_value = self.predict_fn(cfs)
          if self.yloss_type == "hinge_loss":
              yloss = np.zeros(len(predicted_value))
              for i in range(len(predicted_value)):
                  if (
                      not desired_range[0]
                      <= predicted_value[i]
                      <= desired_range[1]
                  ):
                      yloss[i] = min(
                          abs(predicted_value[i] - desired_range[0]),
                          abs(predicted_value[i] - desired_range[1]),
                      )
          return yloss
  
imports: import copy
  import random
  import timeit
  import numpy
  import pandas
  from raiutils.exceptions import UserConfigValidationException
  from dice_ml import diverse_counterfactuals
  from dice_ml.constants import ModelTypes
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
label_desc: Use image node_id 12 for calling the DiceGenetic obj's underlying member method code with example usage: obj.compute_yloss(cfs, desired_range, desired_class) and returns: yloss, yloss