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: Compute the default cost matrix.
  
  :param var_p: The p-wasserstein distance.
  :param kernel_size: Kernel size for computing the cost matrix.
  :return: The cost matrix.
docstr_tok: ["Compute","the","default","cost","matrix",".",":","param","var_p",":","The","p-wasserstein","distance",".",":","param","kernel_size",":","Kernel","size","for","computing","the","cost","matrix",".",":","return",":","The","cost","matrix","."]
code: def _compute_cost_matrix(var_p: int, kernel_size: int) -> np.ndarray:
      """
      Compute the default cost matrix.
  
      :param var_p: The p-wasserstein distance.
      :param kernel_size: Kernel size for computing the cost matrix.
      :return: The cost matrix.
      """
      center = kernel_size // 2
      cost_matrix = np.zeros((kernel_size, kernel_size))
  
      for i in range(kernel_size):
          for j in range(kernel_size):
              # The code of the paper of this attack (https://arxiv.org/abs/1902.07906) implements the cost as:
              # cost_matrix[i, j] = (abs(i - center) ** 2 + abs(j - center) ** 2) ** (p / 2)
              # which only can reproduce L2-norm for p=1 correctly
              cost_matrix[i, j] = (
                  abs(i - center) ** var_p + abs(j - center) ** var_p
              ) ** (1 / var_p)
  
      return cost_matrix
  
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 9 for calling the Wasserstein obj's underlying member method code with example usage: obj._compute_cost_matrix(var_p, kernel_size) and returns: cost_matrix