code: def _check_valid_module(inputs_grad_fn, outputs) -> bool:
      def is_output_cloned(output_fn, input_grad_fn) -> bool:
          """
          Checks if the output has been cloned. This happens especially in case of
          layer deeplift.
          """
          return (
              output_fn[0].next_functions is not None
              and output_fn[0].next_functions[0][0] == input_grad_fn
          )
  
      curr_fn = outputs.grad_fn
      first_next = curr_fn.next_functions[0]
      try:
          # if `inputs` in the input to the network then the grad_fn is None and
          # for that input backward_hook isn't computed. That's the reason why we
          # need to check on `inputs_grad_fns[first_next[1]]` being None.
          return (
              inputs_grad_fn is None
              or first_next[0] == inputs_grad_fn
              or is_output_cloned(first_next, inputs_grad_fn)
          )
      except IndexError:
          return False
  
imports: import typing
  import warnings
  from typing import Any, Callable, List, Tuple, Union, cast
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from torch.nn import Module
  from torch.utils.hooks import RemovableHandle
  from captum.attr._utils.attribution import GradientAttribution
  from captum.attr._utils.common import ExpansionTypes, _call_custom_attribution_func, _compute_conv_delta_and_format_attrs, _expand_additional_forward_args, _expand_target, _format_additional_forward_args, _format_attributions, _format_baseline, _format_callable_baseline, _format_input, _format_tensor_into_tuples, _is_tuple, _run_forward, _tensorize_baseline, _validate_input
  from captum.attr._utils.gradient import apply_gradient_requirements, undo_gradient_requirements
  from captum.attr._utils.typing import BaselineType, Literal, TargetType, TensorOrTupleOfTensorsGeneric
label_desc: Use image node_id 1 for calling a global function with example usage: _check_valid_module(inputs_grad_fn, outputs) and returns: unknown, unknown, False