code: def squared_loss(
      y_true: np.ndarray,
      y_pred: np.ndarray,
      sample_weight: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      """Computes the per-example squared loss.
  
      Args:
        y_true: numpy array of shape (num_samples,) representing the true labels.
        y_pred: numpy array of shape (num_samples,) representing the predictions.
        sample_weight: a vector of weights of shape (num_samples, ) that are
          assigned to individual samples. If not provided, then each sample is
          given unit weight. Only the LogisticRegressionAttacker and the
          RandomForestAttacker support sample weights.
  
      Returns:
        the squared loss of each sample.
      """
      if y_true.ndim != 1:
          logging.warning(
              (
                  "Squared loss expects the labels to have shape "
                  "(num_examples, ) but got shape %s. Will use np.squeeze."
              ),
              y_true.shape,
          )
          y_true = np.squeeze(y_true)
      if y_pred.ndim != 1:
          logging.warning(
              (
                  "Squared loss expects the predictions to have shape "
                  "(num_examples, ) but got shape %s. Will use np.squeeze."
              ),
              y_pred.shape,
          )
          y_pred = np.squeeze(y_pred)
      if y_true.shape != y_pred.shape:
          raise ValueError(
              "Squared loss expects the labels and predictions to have "
              "shape (num_examples, ), but after np.squeeze, the shapes "
              "are %s and %s." % (y_true.shape, y_pred.shape)
          )
      if sample_weight is None:
          # If sample weights are not provided, set them to 1.0.
          sample_weight = 1.0
      return sample_weight * (y_true - y_pred) ** 2
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/utils.py
imports: import enum
  import logging
  import numbers
  from typing import Callable, Iterable, Optional, Union
  import numpy
  from scipy import special
label_desc: Use image node_id 2 for calling a global function with example usage: squared_loss(y_true, y_pred, sample_weight) and returns: unknown