code: def maxpool(
      module: Module,
      pool_func: Callable,
      unpool_func: Callable,
      inputs,
      outputs,
      grad_input,
      grad_output,
      eps: float = 1e-10,
  ):
      with torch.no_grad():
          input, input_ref = inputs.chunk(2)
          output, output_ref = outputs.chunk(2)
  
          delta_in = input - input_ref
          delta_in = torch.cat(2 * [delta_in])
          # Extracts cross maximum between the outputs of maxpool for the
          # actual inputs and its corresponding references. In case the delta outputs
          # for the references are larger the method relies on the references and
          # corresponding gradients to compute the multiplies and contributions.
          delta_out_xmax = torch.max(output, output_ref)
          delta_out = torch.cat(
              [delta_out_xmax - output_ref, output - delta_out_xmax]
          )
  
          _, indices = pool_func(
              module.input,
              module.kernel_size,
              module.stride,
              module.padding,
              module.dilation,
              module.ceil_mode,
              True,
          )
          grad_output_updated = grad_output
          (
              unpool_grad_out_delta,
              unpool_grad_out_ref_delta,
          ) = torch.chunk(
              unpool_func(
                  grad_output_updated * delta_out,
                  indices,
                  module.kernel_size,
                  module.stride,
                  module.padding,
                  list(cast(torch.Size, module.input.shape)),
              ),
              2,
          )
  
      unpool_grad_out_delta = (
          unpool_grad_out_delta + unpool_grad_out_ref_delta
      )
      unpool_grad_out_delta = torch.cat(2 * [unpool_grad_out_delta])
  
      if grad_input.shape != inputs.shape:
          raise AssertionError(
              "A problem occurred during maxpool modul's backward pass. "
              "The gradients with respect to inputs include only a "
              "subset of inputs. More details about this issue can "
              "be found here: "
              "https://pytorch.org/docs/stable/"
              "nn.html#torch.nn.Module.register_backward_hook "
              "This can happen for example if you attribute to the outputs of a "
              "MaxPool. As a workaround, please, attribute to the inputs of "
              "the following layer."
          )
  
      new_grad_inp = torch.where(
          abs(delta_in) < eps,
          grad_input[0],
          unpool_grad_out_delta / delta_in,
      )
      return new_grad_inp
  
imports: import typing
  import warnings
  from typing import Any, Callable, cast, List, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from captum._utils.common import _expand_additional_forward_args, _expand_target, _format_additional_forward_args, _format_baseline, _format_output, _format_tensor_into_tuples, _is_tuple, _register_backward_hook, _run_forward, _select_targets, ExpansionTypes
  from captum._utils.gradient import apply_gradient_requirements, undo_gradient_requirements
  from captum._utils.typing import BaselineType, Literal, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._utils.attribution import GradientAttribution
  from captum.attr._utils.common import _call_custom_attribution_func, _compute_conv_delta_and_format_attrs, _format_callable_baseline, _tensorize_baseline, _validate_input
  from captum.log import log_usage
  from torch import Tensor
  from torch.nn import Module
  from torch.utils.hooks import RemovableHandle
label_desc: Use image node_id 6 for calling a global function with example usage: maxpool(module, pool_func, unpool_func, inputs, outputs, grad_input, grad_output, eps) and returns: new_grad_inp