code: def test_prune_grad(self):
      @torch.jit.script
      def t(input, bias):
          return torch.nn.functional.relu(input + bias)
  
      input = torch.randn(2, 8, requires_grad=True)
      bias = torch.randn(
          8, requires_grad=False
      )  # bias does NOT require grad
      NUM_PROFILED_RUNS = 1
      with num_profiled_runs(NUM_PROFILED_RUNS):
          WARMUP = 3  # 2 runs to reach backward + 1 to optimize it
          for x in range(WARMUP):
              o = t(input, bias)
              o.sum().backward()
  
          fwd_plan = list(t.get_debug_state().execution_plans.values())[
              0
          ]
          bwd_graph = list(
              fwd_plan.code.grad_executor_states()[
                  0
              ].execution_plans.values()
          )[0].graph
          tup = next(bwd_graph.outputs())
          self.assertEqual(len(list(tup.node().inputs())), 1)
  
imports: import os
  import sys
  import unittest
  from torch.testing._internal.common_utils import GRAPH_EXECUTOR, ProfilingMode, num_profiled_runs, enable_profiling_mode_for_profiling_tests
  from torch.testing._internal.common_jit import check_against_reference
  import torch
  from torch.testing._internal.jit_utils import JitTestCase, disable_autodiff_subgraph_inlining
  from torch.testing import FileCheck
  from typing import List, Tuple, Optional
label_desc: Use image node_id 10 for calling the TestAutodiffSubgraphSlicing obj's underlying member method code with example usage: obj.test_prune_grad() and returns: torch