code: def test_populated_test_upgrader_graph(self):
      @torch.jit.script
      def f():
          return 0
  
      buffer = io.BytesIO()
      torch.jit.save(f, buffer)
      buffer.seek(0)
      torch.jit.load(buffer)
  
      # upgrader map should have populated now
      upgraders_size = torch._C._get_upgraders_map_size()
  
      test_map = {
          "a": str(torch._C.Graph()),
          "c": str(torch._C.Graph()),
      }
      torch._C._test_only_populate_upgraders(test_map)
      upgraders_size_after_test = torch._C._get_upgraders_map_size()
      self.assertEqual(upgraders_size_after_test - upgraders_size, 2)
      upgraders_dump = torch._C._dump_upgraders_map()
      self.assertTrue("a" in upgraders_dump)
      self.assertTrue("c" in upgraders_dump)
  
      torch._C._test_only_remove_upgraders(test_map)
      upgraders_size_after_remove_test = (
          torch._C._get_upgraders_map_size()
      )
      self.assertTrue(
          upgraders_size_after_remove_test == upgraders_size
      )
      upgraders_dump_after_remove_test = torch._C._dump_upgraders_map()
      self.assertTrue("a" not in upgraders_dump_after_remove_test)
      self.assertTrue("c" not in upgraders_dump_after_remove_test)
  
imports: import io
  import os
  import sys
  import torch
  import zipfile
  from torch.testing import FileCheck
  from typing import Union
  from torch.testing._internal.jit_utils import JitTestCase
label_desc: Use image node_id 4 for calling the TestUpgraders obj's underlying member method code with example usage: obj.test_populated_test_upgrader_graph() and returns: int