class_docstr: Implements ``Wasserstein Adversarial Examples via Projected Sinkhorn Iterations`` as evasion attack.
  
  | Paper link: https://arxiv.org/abs/1902.07906
class_docstr_tok: ["Implements","``","Wasserstein","Adversarial","Examples","via","Projected","Sinkhorn","Iterations","``","as","evasion","attack",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1902.07906"]
docstr: Extract sliding local blocks from a batched input.
  
  :param x: A batched input of shape `batch x channel x width x height`.
  :param kernel_size: Kernel size for computing the cost matrix.
  :param padding: Controls the amount of implicit zero-paddings on both sides for padding number of points
      for each dimension before reshaping.
  :return: Sliding local blocks.
docstr_tok: ["Extract","sliding","local","blocks","from","a","batched","input",".",":","param","x",":","A","batched","input","of","shape","`","batch","x","channel","x","width","x","height","`",".",":","param","kernel_size",":","Kernel","size","for","computing","the","cost","matrix",".",":","param","padding",":","Controls","the","amount","of","implicit","zero-paddings","on","both","sides","for","padding","number","of","points","for","each","dimension","before","reshaping",".",":","return",":","Sliding","local","blocks","."]
code: def _unfold(
      x: np.ndarray, kernel_size: int, padding: int
  ) -> np.ndarray:
      """
      Extract sliding local blocks from a batched input.
  
      :param x: A batched input of shape `batch x channel x width x height`.
      :param kernel_size: Kernel size for computing the cost matrix.
      :param padding: Controls the amount of implicit zero-paddings on both sides for padding number of points
          for each dimension before reshaping.
      :return: Sliding local blocks.
      """
      # Do padding
      shape = tuple(np.array(x.shape[2:]) + padding * 2)
      x_pad = np.zeros(x.shape[:2] + shape)
      x_pad[
          :,
          :,
          padding : (shape[0] - padding),
          padding : (shape[1] - padding),
      ] = x
  
      # Do unfolding
      res_dim_0 = x.shape[0]
      res_dim_1 = x.shape[1] * kernel_size**2
      res_dim_2 = (shape[0] - kernel_size + 1) * (
          shape[1] - kernel_size + 1
      )
      result = np.zeros((res_dim_0, res_dim_1, res_dim_2))
  
      for i in range(shape[0] - kernel_size + 1):
          for j in range(shape[1] - kernel_size + 1):
              patch = x_pad[
                  :, :, i : (i + kernel_size), j : (j + kernel_size)
              ]
              patch = patch.reshape(x.shape[0], -1)
              result[:, :, i * (shape[1] - kernel_size + 1) + j] = patch
  
      return result
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, TYPE_CHECKING
  import numpy
  from scipy.special import lambertw
  from tqdm.auto import trange
  from art.config import ART_NUMPY_DTYPE
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.attacks.attack import EvasionAttack
  from art.utils import get_labels_np_array, check_and_transform_label_format
label_desc: Use image node_id 11 for calling the Wasserstein obj's underlying member method code with example usage: obj._unfold(x, kernel_size, padding) and returns: result