code: def test_update(self):
      # mapping argument
      d = self._empty_mapping()
      d.update(self.other)
      self.assertEqual(list(d.items()), list(self.other.items()))
  
      # No argument
      d = self._empty_mapping()
      d.update()
      self.assertEqual(d, self._empty_mapping())
  
      # item sequence
      d = self._empty_mapping()
      d.update(self.other.items())
      self.assertEqual(list(d.items()), list(self.other.items()))
  
      # Iterator
      d = self._empty_mapping()
      d.update(self.other.items())
      self.assertEqual(list(d.items()), list(self.other.items()))
  
      # FIXME: Doesn't work with UserDict
      # self.assertRaises((TypeError, AttributeError), d.update, None)
      self.assertRaises((TypeError, AttributeError), d.update, 42)
  
      outerself = self
  
      class SimpleUserDict:
          def __init__(self):
              self.d = outerself.reference
  
          def keys(self):
              return self.d.keys()
  
          def __getitem__(self, i):
              return self.d[i]
  
      d.clear()
      d.update(SimpleUserDict())
      i1 = sorted((id(k), v) for k, v in d.items())
      i2 = sorted((id(k), v) for k, v in self.reference.items())
      self.assertEqual(i1, i2)
  
      class Exc(Exception):
          pass
  
      d = self._empty_mapping()
  
      class FailingUserDict:
          def keys(self):
              raise Exc
  
      self.assertRaises(Exc, d.update, FailingUserDict())
  
      d.clear()
  
      class FailingUserDict:
          def keys(self):
              class BogonIter:
                  def __init__(self):
                      self.i = 1
  
                  def __iter__(self):
                      return self
  
                  def __next__(self):
                      if self.i:
                          self.i = 0
                          return "a"
                      raise Exc
  
              return BogonIter()
  
          def __getitem__(self, key):
              return key
  
      self.assertRaises(Exc, d.update, FailingUserDict())
  
      class FailingUserDict:
          def keys(self):
              class BogonIter:
                  def __init__(self):
                      self.i = ord("a")
  
                  def __iter__(self):
                      return self
  
                  def __next__(self):
                      if self.i <= ord("z"):
                          rtn = chr(self.i)
                          self.i += 1
                          return rtn
                      raise StopIteration
  
              return BogonIter()
  
          def __getitem__(self, key):
              raise Exc
  
      self.assertRaises(Exc, d.update, FailingUserDict())
  
      d = self._empty_mapping()
  
      class badseq:
          def __iter__(self):
              return self
  
          def __next__(self):
              raise Exc()
  
      self.assertRaises(Exc, d.update, badseq())
  
      self.assertRaises(ValueError, d.update, [(1, 2, 3)])
  
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 14 for calling the WeakKeyDictionaryTestCase obj's underlying member method code with example usage: obj.test_update() and returns: self, self, BogonIter, key, BogonIter, self, self, self, str, rtn