class_docstr: A perturbation based approach to compute attribution, involving
  replacing each contiguous rectangular region with a given baseline /
  reference, and computing the difference in output. For features located
  in multiple regions (hyperrectangles), the corresponding output differences
  are averaged to compute the attribution for that feature.
  
  The first patch is applied with the corner aligned with all indices 0,
  and strides are applied until the entire dimension range is covered. Note
  that this may cause the final patch applied in a direction to be cut-off
  and thus smaller than the target occlusion shape.
  
  More details regarding the occlusion (or grey-box / sliding window)
  method can be found in the original paper and in the DeepExplain
  implementation.
  https://arxiv.org/abs/1311.2901
  https://github.com/marcoancona/DeepExplain/blob/master/deepexplain\
  /tensorflow/methods.py#L401
class_docstr_tok: ["A","perturbation","based","approach","to","compute","attribution",",","involving","replacing","each","contiguous","rectangular","region","with","a","given","baseline","\/","reference",",","and","computing","the","difference","in","output",".","For","features","located","in","multiple","regions","(","hyperrectangles",")",",","the","corresponding","output","differences","are","averaged","to","compute","the","attribution","for","that","feature",".","The","first","patch","is","applied","with","the","corner","aligned","with","all","indices","0",",","and","strides","are","applied","until","the","entire","dimension","range","is","covered",".","Note","that","this","may","cause","the","final","patch","applied","in","a","direction","to","be","cut-off","and","thus","smaller","than","the","target","occlusion","shape",".","More","details","regarding","the","occlusion","(","or","grey-box","\/","sliding","window",")","method","can","be","found","in","the","original","paper","and","in","the","DeepExplain","implementation",".","https",":","\/\/arxiv.org\/abs\/1311.2901","https",":","\/\/github.com\/marcoancona\/DeepExplain\/blob\/master\/deepexplain\\","\/tensorflow\/methods.py","#","L401"]
docstr: Ablates given expanded_input tensor with given feature mask, feature range,
  and baselines, and any additional arguments.
  expanded_input shape is (num_features, num_examples, ...)
  with remaining dimensions corresponding to remaining original tensor
  dimensions and num_features = end_feature - start_feature.
  
  input_mask is None for occlusion, and the mask is constructed
  using sliding_window_tensors, strides, and shift counts, which are provided in
  kwargs. baseline is expected to
  be broadcastable to match expanded_input.
  
  This method returns the ablated input tensor, which has the same
  dimensionality as expanded_input as well as the corresponding mask with
  either the same dimensionality as expanded_input or second dimension
  being 1. This mask contains 1s in locations which have been ablated (and
  thus counted towards ablations for that feature) and 0s otherwise.
docstr_tok: ["Ablates","given","expanded_input","tensor","with","given","feature","mask",",","feature","range",",","and","baselines",",","and","any","additional","arguments",".","expanded_input","shape","is","(","num_features",",","num_examples",",","...",")","with","remaining","dimensions","corresponding","to","remaining","original","tensor","dimensions","and","num_features","=","end_feature","-","start_feature",".","input_mask","is","None","for","occlusion",",","and","the","mask","is","constructed","using","sliding_window_tensors",",","strides",",","and","shift","counts",",","which","are","provided","in","kwargs",".","baseline","is","expected","to","be","broadcastable","to","match","expanded_input",".","This","method","returns","the","ablated","input","tensor",",","which","has","the","same","dimensionality","as","expanded_input","as","well","as","the","corresponding","mask","with","either","the","same","dimensionality","as","expanded_input","or","second","dimension","being","1",".","This","mask","contains","1s","in","locations","which","have","been","ablated","(","and","thus","counted","towards","ablations","for","that","feature",")","and","0s","otherwise","."]
code: def _construct_ablated_input(
      self,
      expanded_input: Tensor,
      input_mask: Union[None, Tensor],
      baseline: Union[Tensor, int, float],
      start_feature: int,
      end_feature: int,
      **kwargs: Any,
  ) -> Tuple[Tensor, Tensor]:
      r"""
      Ablates given expanded_input tensor with given feature mask, feature range,
      and baselines, and any additional arguments.
      expanded_input shape is (num_features, num_examples, ...)
      with remaining dimensions corresponding to remaining original tensor
      dimensions and num_features = end_feature - start_feature.
  
      input_mask is None for occlusion, and the mask is constructed
      using sliding_window_tensors, strides, and shift counts, which are provided in
      kwargs. baseline is expected to
      be broadcastable to match expanded_input.
  
      This method returns the ablated input tensor, which has the same
      dimensionality as expanded_input as well as the corresponding mask with
      either the same dimensionality as expanded_input or second dimension
      being 1. This mask contains 1s in locations which have been ablated (and
      thus counted towards ablations for that feature) and 0s otherwise.
      """
      input_mask = torch.stack(
          [
              self._occlusion_mask(
                  expanded_input,
                  j,
                  kwargs["sliding_window_tensors"],
                  kwargs["strides"],
                  kwargs["shift_counts"],
              )
              for j in range(start_feature, end_feature)
          ],
          dim=0,
      ).long()
      ablated_tensor = (
          expanded_input
          * (
              torch.ones(
                  1, dtype=torch.long, device=expanded_input.device
              )
              - input_mask
          ).to(expanded_input.dtype)
      ) + (baseline * input_mask.to(expanded_input.dtype))
      return ablated_tensor, input_mask
  
file_path: captum/captum/attr/_core/occlusion.py
imports: from typing import Any, Callable, Tuple, Union
  import numpy
  import torch
  from captum._utils.common import _format_tensor_into_tuples
  from captum._utils.typing import BaselineType, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._core.feature_ablation import FeatureAblation
  from captum.attr._utils.common import _format_and_verify_sliding_window_shapes, _format_and_verify_strides
  from captum.log import log_usage
  from torch import Tensor
label_desc: Use image node_id 3 for calling the Occlusion obj's underlying member method code with example usage: obj._construct_ablated_input(expanded_input, input_mask, baseline, start_feature, end_feature) and returns: ablated_tensor,  input_mask