class_docstr: Implements the functionality for albating the image, and retaining only a column
class_docstr_tok: ["Implements","the","functionality","for","albating","the","image",",","and","retaining","only","a","column"]
docstr: Performs ablation on the input x. If no column_pos is specified a random location will be selected.
  
  :param x: input batch.
  :param column_pos: int indicating the start column to retain across all samples in the batch
                     or list of ints of length equal to the number of samples to have a different
                     column retained per sample. If not supplied a random location will be selected.
                     NB, if row_ablation_mode is true then this will be used to act on the rows through
                     transposing the image.
  :param row_pos: Unused.
  :return: Batch ablated according to the locations in column_pos. Data is channel extended to indicate to a
           model if a position is ablated.
docstr_tok: ["Performs","ablation","on","the","input","x",".","If","no","column_pos","is","specified","a","random","location","will","be","selected",".",":","param","x",":","input","batch",".",":","param","column_pos",":","int","indicating","the","start","column","to","retain","across","all","samples","in","the","batch","or","list","of","ints","of","length","equal","to","the","number","of","samples","to","have","a","different","column","retained","per","sample",".","If","not","supplied","a","random","location","will","be","selected",".","NB",",","if","row_ablation_mode","is","true","then","this","will","be","used","to","act","on","the","rows","through","transposing","the","image",".",":","param","row_pos",":","Unused",".",":","return",":","Batch","ablated","according","to","the","locations","in","column_pos",".","Data","is","channel","extended","to","indicate","to","a","model","if","a","position","is","ablated","."]
code: def forward(
      self,
      x: np.ndarray,
      column_pos: Optional[Union[int, list]] = None,
      row_pos: Optional[Union[int, list]] = None,
  ) -> np.ndarray:
      """
      Performs ablation on the input x. If no column_pos is specified a random location will be selected.
  
      :param x: input batch.
      :param column_pos: int indicating the start column to retain across all samples in the batch
                         or list of ints of length equal to the number of samples to have a different
                         column retained per sample. If not supplied a random location will be selected.
                         NB, if row_ablation_mode is true then this will be used to act on the rows through
                         transposing the image.
      :param row_pos: Unused.
      :return: Batch ablated according to the locations in column_pos. Data is channel extended to indicate to a
               model if a position is ablated.
      """
      if not self.channels_first:
          x = np.transpose(x, (0, 3, 1, 2))
  
      x = np.concatenate([x, 1.0 - x], axis=1)
  
      if column_pos is None:
          column_pos = random.randint(0, x.shape[3])
  
      if isinstance(column_pos, list):
          assert len(column_pos) == len(x)
          for i, pos in enumerate(column_pos):
              x[i : i + 1] = self.ablate(x[i : i + 1], pos)
      else:
          x = self.ablate(x, column_pos)
  
      if not self.channels_first:
          x = np.transpose(x, (0, 2, 3, 1))
  
      return x
  
file_path: adversarial-robustness-toolbox/art/estimators/certification/derandomized_smoothing/ablators/tensorflow.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from typing import Optional, Union, Tuple, TYPE_CHECKING
  import random
  import numpy
  from art.estimators.certification.derandomized_smoothing.ablators.ablate import BaseAblator
label_desc: Use image node_id 5 for calling the ColumnAblator obj's underlying member method code with example usage: obj.forward(x, column_pos, row_pos) and returns: x