code: def check_popitem(self, klass, key1, value1, key2, value2):
      weakdict = klass()
      weakdict[key1] = value1
      weakdict[key2] = value2
      self.assertEqual(len(weakdict), 2)
      k, v = weakdict.popitem()
      self.assertEqual(len(weakdict), 1)
      if k is key1:
          self.assertIs(v, value1)
      else:
          self.assertIs(v, value2)
      k, v = weakdict.popitem()
      self.assertEqual(len(weakdict), 0)
      if k is key1:
          self.assertIs(v, value1)
      else:
          self.assertIs(v, value2)
  
imports: import copy
  import gc
  import random
  import threading
  import unittest
  import torch
  from torch.testing._internal.common_utils import find_library_location, IS_FBCODE, IS_MACOS, IS_SANDCASTLE, IS_WINDOWS, run_tests, TestCase
  from torch.utils.weak import _WeakHashRef, WeakIdKeyDictionary
label_desc: Use image node_id 3 for calling the WeakTest obj's underlying member method code with example usage: obj.check_popitem(klass, key1, value1, key2, value2) without return types