code: def test_add_or_replace(self):
      fn_captures = capture_container.FunctionCaptures()
      fn_captures.add_or_replace("a", 1, -1, is_by_ref=False)
      fn_captures.add_or_replace("aa", 1, -1, 0, is_by_ref=True)
  
      with self.subTest("add_by_val"):
          self.assertLen(fn_captures.by_val_internal, 1)
          self.assertLen(fn_captures.by_val_external, 1)
  
      with self.subTest("add_by_ref"):
          self.assertLen(fn_captures.by_ref_internal, 1)
          self.assertLen(fn_captures.by_ref_external, 1)
          self.assertLen(fn_captures.by_ref_tracetype, 1)
  
      fn_captures.add_or_replace("a", 2, -2, is_by_ref=False)
      with self.subTest("replace_by_val"):
          self.assertLen(fn_captures.by_val_internal, 1)
          self.assertLen(fn_captures.by_val_external, 1)
          self.assertEqual(fn_captures.by_val_external["a"], 2)
          self.assertEqual(fn_captures.by_val_internal["a"], -2)
  
file_path: tensorflow-upstream/tensorflow/core/function/capture/capture_container_test.py
imports: import copy
  from absl.testing import parameterized
  from tensorflow.core.function import trace_type
  from tensorflow.core.function.capture import capture_container
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the FunctionCapturesTest obj's underlying member method code with example usage: obj.test_add_or_replace() without return types