code: def maxpool(module, grad_input, grad_output):
      pool_to_unpool = {
          "MaxPool1d": torch.nn.functional.max_unpool1d,
          "MaxPool2d": torch.nn.functional.max_unpool2d,
          "MaxPool3d": torch.nn.functional.max_unpool3d,
      }
      pool_to_function = {
          "MaxPool1d": torch.nn.functional.max_pool1d,
          "MaxPool2d": torch.nn.functional.max_pool2d,
          "MaxPool3d": torch.nn.functional.max_pool3d,
      }
      delta_in = (
          module.x[: int(module.x.shape[0] / 2)]
          - module.x[int(module.x.shape[0] / 2) :]
      )
      dup0 = [2] + [1 for i in delta_in.shape[1:]]
      # we also need to check if the output is a tuple
      y, ref_output = torch.chunk(module.y, 2)
      cross_max = torch.max(y, ref_output)
      diffs = torch.cat([cross_max - ref_output, y - cross_max], 0)
  
      # all of this just to unpool the outputs
      with torch.no_grad():
          _, indices = pool_to_function[module.__class__.__name__](
              module.x,
              module.kernel_size,
              module.stride,
              module.padding,
              module.dilation,
              module.ceil_mode,
              True,
          )
          xmax_pos, rmax_pos = torch.chunk(
              pool_to_unpool[module.__class__.__name__](
                  grad_output[0] * diffs,
                  indices,
                  module.kernel_size,
                  module.stride,
                  module.padding,
                  list(module.x.shape),
              ),
              2,
          )
  
      grad_input = [None for _ in grad_input]
      grad_input[0] = torch.where(
          torch.abs(delta_in) < 1e-7,
          torch.zeros_like(delta_in),
          (xmax_pos + rmax_pos) / delta_in,
      ).repeat(dup0)
  
      return tuple(grad_input)
  
file_path: shap/shap/explainers/_deep/deep_pytorch.py
imports: import warnings
  import numpy
  from packaging import version
  from .._explainer import Explainer
  from .deep_utils import _check_additivity
label_desc: Use image node_id 5 for calling a global function with example usage: maxpool(module, grad_input, grad_output) and returns: tuple