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: Minimize the total variance objective function.
  
  :param x: Original image.
  :param mask: A matrix that decides which points are kept.
  :return: A new image.
docstr_tok: ["Minimize","the","total","variance","objective","function",".",":","param","x",":","Original","image",".",":","param","mask",":","A","matrix","that","decides","which","points","are","kept",".",":","return",":","A","new","image","."]
code: def _minimize(self, x: np.ndarray, mask: np.ndarray) -> np.ndarray:
      """
      Minimize the total variance objective function.
  
      :param x: Original image.
      :param mask: A matrix that decides which points are kept.
      :return: A new image.
      """
      z_min = x.copy()
  
      for i in range(x.shape[2]):
          res = minimize(
              self._loss_func,
              z_min[:, :, i].flatten(),
              (x[:, :, i], mask[:, :, i], self.norm, self.lamb),
              method=self.solver,
              jac=self._deri_loss_func,
              options={"maxiter": self.max_iter},
          )
          z_min[:, :, i] = np.reshape(res.x, z_min[:, :, i].shape)
  
      return z_min
  
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 3 for calling the TotalVarMin obj's underlying member method code with example usage: obj._minimize(x, mask) and returns: z_min