class_docstr: Implement the total variance minimization defence approach.
  
  | Paper link: https://openreview.net/forum?id=SyJ7ClWCb
  
  | Please keep in mind the limitations of defences. For more information on the limitations of this
      defence, see https://arxiv.org/abs/1802.00420 . For details on how to evaluate classifier security in general,
      see https://arxiv.org/abs/1902.06705
class_docstr_tok: ["Implement","the","total","variance","minimization","defence","approach",".","|","Paper","link",":","https",":","\/\/openreview.net\/forum","?","id=SyJ7ClWCb","|","Please","keep","in","mind","the","limitations","of","defences",".","For","more","information","on","the","limitations","of","this","defence",",","see","https",":","\/\/arxiv.org\/abs\/1802.00420",".","For","details","on","how","to","evaluate","classifier","security","in","general",",","see","https",":","\/\/arxiv.org\/abs\/1902.06705"]
docstr: Loss function to be minimized.
  
  :param z_init: Initial guess.
  :param x: Original image.
  :param mask: A matrix that decides which points are kept.
  :param norm: The norm (positive integer).
  :param lamb: The lambda parameter in the objective function.
  :return: Loss value.
docstr_tok: ["Loss","function","to","be","minimized",".",":","param","z_init",":","Initial","guess",".",":","param","x",":","Original","image",".",":","param","mask",":","A","matrix","that","decides","which","points","are","kept",".",":","param","norm",":","The","norm","(","positive","integer",")",".",":","param","lamb",":","The","lambda","parameter","in","the","objective","function",".",":","return",":","Loss","value","."]
code: def _loss_func(
      z_init: np.ndarray,
      x: np.ndarray,
      mask: np.ndarray,
      norm: int,
      lamb: float,
  ) -> float:
      """
      Loss function to be minimized.
  
      :param z_init: Initial guess.
      :param x: Original image.
      :param mask: A matrix that decides which points are kept.
      :param norm: The norm (positive integer).
      :param lamb: The lambda parameter in the objective function.
      :return: Loss value.
      """
      res = np.sqrt(
          np.power(z_init - x.flatten(), 2).dot(mask.flatten())
      )
      z_init = np.reshape(z_init, x.shape)
      res += (
          lamb
          * np.linalg.norm(
              z_init[1:, :] - z_init[:-1, :], norm, axis=1
          ).sum()
      )
      res += (
          lamb
          * np.linalg.norm(
              z_init[:, 1:] - z_init[:, :-1], norm, axis=0
          ).sum()
      )
  
      return res
  
file_path: adversarial-robustness-toolbox/art/defences/preprocessor/variance_minimization.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, TYPE_CHECKING
  import numpy
  from scipy.optimize import minimize
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.defences.preprocessor.preprocessor import Preprocessor
label_desc: Use image node_id 4 for calling the TotalVarMin obj's underlying member method code with example usage: obj._loss_func(z_init, x, mask, norm, lamb) and returns: res