class_docstr: Loss base class.
  
  To be implemented by subclasses:
  
  * `call()`: Contains the logic for loss calculation using `y_true`,
      `y_pred`.
  
  Example subclass implementation:
  
  ```python
  class MeanSquaredError(Loss):
      def call(self, y_true, y_pred):
          return ops.mean(ops.square(y_pred - y_true), axis=-1)
  ```
class_docstr_tok: ["Loss","base","class",".","To","be","implemented","by","subclasses",":","*","`","call","(",")","`",":","Contains","the","logic","for","loss","calculation","using","`","y_true","`",",","`","y_pred","`",".","Example","subclass","implementation",":","``","`","python","class","MeanSquaredError","(","Loss",")",":","def","call","(","self",",","y_true",",","y_pred",")",":","return","ops.mean","(","ops.square","(","y_pred","-","y_true",")",",","axis=-1",")","``","`"]
code: def __call__(self, y_true, y_pred, sample_weight=None):
      in_mask = getattr(y_pred, "_keras_mask", None)
  
      with ops.name_scope(self.name):
          y_pred = tree.map_structure(
              lambda x: ops.convert_to_tensor(x, dtype=self.dtype),
              y_pred,
          )
          y_true = tree.map_structure(
              lambda x: ops.convert_to_tensor(x, dtype=self.dtype),
              y_true,
          )
  
          losses = self.call(y_true, y_pred)
          out_mask = getattr(losses, "_keras_mask", None)
  
          if in_mask is not None and out_mask is not None:
              mask = in_mask & out_mask
          elif in_mask is not None:
              mask = in_mask
          elif out_mask is not None:
              mask = out_mask
          else:
              mask = None
  
          return reduce_weighted_values(
              losses,
              sample_weight=sample_weight,
              mask=mask,
              reduction=self.reduction,
              dtype=self.dtype,
          )
  
file_path: keras/keras/losses/loss.py
imports: import tree
  from keras import backend
  from keras import ops
  from keras.api_export import keras_export
  from keras.utils.naming import auto_name
label_desc: Use image node_id 2 for calling the Loss obj's underlying member method code with example usage: obj.__call__(y_true, y_pred, sample_weight) and returns: reduce_weighted_values