code: def test_weak_keyed_bad_delitem(self):
      d = WeakIdKeyDictionary()
      o = torch.randn(1)
      # An attempt to delete an object that isn't there should raise
      # KeyError.  It didn't before 2.3.
      self.assertRaises(KeyError, d.__delitem__, o)
      self.assertRaises(KeyError, d.__getitem__, o)
  
      # If a key isn't of a weakly referencable type, __getitem__ and
      # __setitem__ raise TypeError.  __delitem__ should too.
      self.assertRaises(TypeError, d.__delitem__, 13)
      self.assertRaises(TypeError, d.__getitem__, 13)
      self.assertRaises(TypeError, d.__setitem__, 13, 13)
  
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 11 for calling the WeakTest obj's underlying member method code with example usage: obj.test_weak_keyed_bad_delitem() without return types