class_docstr: Wrapper class for importing Keras regression models.
class_docstr_tok: ["Wrapper","class","for","importing","Keras","regression","models","."]
docstr: Compute the MSE loss of the regressor for predictions `pred`. Does not apply preprocessing to the given `y`.
  
  :param pred: Model predictions.
  :param y: Target values.
  :param reduction: Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'.
             'none': no reduction will be applied
             'mean': the sum of the output will be divided by the number of elements in the output,
             'sum': the output will be summed.
  :return: Loss values.
docstr_tok: ["Compute","the","MSE","loss","of","the","regressor","for","predictions","`","pred","`",".","Does","not","apply","preprocessing","to","the","given","`","y","`",".",":","param","pred",":","Model","predictions",".",":","param","y",":","Target","values",".",":","param","reduction",":","Specifies","the","reduction","to","apply","to","the","output",":","'none","'","|","'mean","'","|","'sum","'",".","'none","'",":","no","reduction","will","be","applied","'mean","'",":","the","sum","of","the","output","will","be","divided","by","the","number","of","elements","in","the","output",",","'sum","'",":","the","output","will","be","summed",".",":","return",":","Loss","values","."]
code: def compute_loss_from_predictions(  # pylint: disable=W0221
      self,
      pred: np.ndarray,
      y: np.ndarray,
      reduction: str = "none",
      **kwargs,
  ) -> np.ndarray:
      """
      Compute the MSE loss of the regressor for predictions `pred`. Does not apply preprocessing to the given `y`.
  
      :param pred: Model predictions.
      :param y: Target values.
      :param reduction: Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'.
                 'none': no reduction will be applied
                 'mean': the sum of the output will be divided by the number of elements in the output,
                 'sum': the output will be summed.
      :return: Loss values.
      """
      if not self._losses:
          raise NotImplementedError(
              "loss method is only supported for keras versions >= 2.3.1"
          )
  
      if self.is_tensorflow:
          import tensorflow.keras.backend as k  # pylint: disable=E0611
      else:
          import keras.backend as k
  
      if self._orig_loss and hasattr(self._orig_loss, "reduction"):
          prev_reduction = self._orig_loss.reduction
          if hasattr(self._losses, "Reduction"):
              self._orig_loss.reduction = self._losses.Reduction.NONE
          loss = self._orig_loss(y, pred)
          self._orig_loss.reduction = prev_reduction
      else:
          prev_reduction = []
          predictions = k.constant(pred)
          y_preprocessed = k.constant(y)
          for loss_function in self._model.loss_functions:
              prev_reduction.append(loss_function.reduction)
              if hasattr(self._losses, "Reduction"):
                  loss_function.reduction = self._losses.Reduction.NONE
          loss = self._loss_function(y_preprocessed, predictions)
          for i, loss_function in enumerate(self._model.loss_functions):
              loss_function.reduction = prev_reduction[i]
  
      loss_value = k.eval(loss)
  
      if reduction == "none":
          pass
      elif reduction == "mean":
          loss_value = np.mean(loss_value, axis=0)
      elif reduction == "sum":
          loss_value = np.sum(loss_value, axis=0)
  
      return loss_value
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import time
  from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  import six
  from art import config
  from art.estimators.keras import KerasEstimator
  from art.estimators.regression.regressor import RegressorMixin
label_desc: Use image node_id 7 for calling the KerasRegressor obj's underlying member method code with example usage: obj.compute_loss_from_predictions(pred, y, reduction) and returns: loss_value