code: def test_list_indexing_removal(self):
      @torch.jit.script
      def out_of_bounds():
          x = [1, 2]
          x[4] = 3
          return x
  
      torch._C._jit_pass_remove_mutation(out_of_bounds.graph)
      FileCheck().check("set_item").run(out_of_bounds.graph)
  
      @torch.jit.script
      def unknown(y: int):
          x = [1, 2]
          x[y] = 3
          return x
  
      torch._C._jit_pass_remove_mutation(out_of_bounds.graph)
      FileCheck().check("set_item").run(out_of_bounds.graph)
  
      def successful():
          x = [1, 2, 3]
          x[0] = 4
          x[-1] = 0
          return x
  
      scripted_fn = torch.jit.script(successful)
      torch._C._jit_pass_remove_mutation(scripted_fn.graph)
      FileCheck().check_not("set_item").run(scripted_fn.graph)
      self.checkScript(successful, ())
  
      def successful():
          x = [1, 2, 3]
          x[0] = 4
          x[-1] = 0
          return x
  
      scripted_fn = torch.jit.script(successful)
      torch._C._jit_pass_remove_mutation(scripted_fn.graph)
      FileCheck().check_not("set_item").run(scripted_fn.graph)
      self.checkScript(successful, ())
  
      def successful():
          x = [1]
          x[-1] = 3
          return x
  
      scripted_fn = torch.jit.script(successful)
      torch._C._jit_pass_remove_mutation(scripted_fn.graph)
      FileCheck().check_not("set_item").run(scripted_fn.graph)
      self.checkScript(successful, ())
  
file_path: pytorch/test/jit/test_remove_mutation.py
imports: import os
  import sys
  import torch
  from torch.testing import FileCheck
  from typing import List
  from torch.testing._internal.jit_utils import JitTestCase, freeze_rng_state
label_desc: Use image node_id 7 for calling the TestRemoveMutation obj's underlying member method code with example usage: obj.test_list_indexing_removal() and returns: x, x, x, x, x