code: def construct_neuron_grad_fn(
      layer: Module,
      neuron_index: Union[int, Tuple[int, ...]],
      device_ids: Union[None, List[int]] = None,
      attribute_to_neuron_input: bool = False,
  ) -> Callable:
      def grad_fn(
          forward_fn: Callable,
          inputs: TensorOrTupleOfTensorsGeneric,
          target_ind: TargetType = None,
          additional_forward_args: Any = None,
      ) -> Tuple[Tensor, ...]:
          _, grads, _ = _forward_layer_eval_with_neuron_grads(
              forward_fn,
              inputs,
              layer,
              additional_forward_args,
              gradient_neuron_index=neuron_index,
              device_ids=device_ids,
              attribute_to_layer_input=attribute_to_neuron_input,
          )
          return grads
  
      return grad_fn
  
imports: import threading
  import typing
  import warnings
  from typing import Any, Callable, Dict, List, Tuple, Union, cast
  import torch
  from torch import Tensor, device
  from torch.nn import Module
  from captum.attr._utils.batching import _reduce_list, _sort_key_list
  from captum.attr._utils.common import _run_forward, _verify_select_column
  from captum.attr._utils.typing import Literal, TargetType, TensorOrTupleOfTensorsGeneric
label_desc: Use image node_id 17 for calling a global function with example usage: construct_neuron_grad_fn(layer, neuron_index, device_ids, attribute_to_neuron_input) and returns: grad_fn, grads