code: def apply_gradient_requirements(
      inputs: Tuple[Tensor, ...]
  ) -> List[bool]:
      """
      Iterates through tuple on input tensors and sets requires_grad to be true on
      each Tensor, and ensures all grads are set to zero. To ensure that the input
      is returned to its initial state, a list of flags representing whether or not
       a tensor originally required grad is returned.
      """
      assert isinstance(
          inputs, tuple
      ), "Inputs should be wrapped in a tuple prior to preparing for gradients"
      grad_required = []
      for index, input in enumerate(inputs):
          assert isinstance(
              input, torch.Tensor
          ), "Given input is not a torch.Tensor"
          grad_required.append(input.requires_grad)
          if not input.requires_grad:
              warnings.warn(
                  "Input Tensor %d did not already require gradients, "
                  "required_grads has been set automatically." % index
              )
              input.requires_grad_()
          if input.grad is not None:
              if torch.sum(torch.abs(input.grad)).item() > 1e-7:
                  warnings.warn(
                      "Input Tensor %d had a non-zero gradient tensor, "
                      "which is being reset to 0." % index
                  )
              input.grad.zero_()
      return grad_required
  
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 1 for calling a global function with example usage: apply_gradient_requirements(inputs) and returns: grad_required