code: def test_flat_replace(self):
      results = FakeResults(0)
      self.assertEqual(
          unnest.replace_innermost(results, unique_core=1).unique_core,
          1,
      )
      self.assertEqual(
          unnest.replace_innermost(
              results, return_unused=True, unique_core=1, foo=2
          ),
          (FakeResults(1), {"foo": 2}),
      )
      self.assertEqual(
          unnest.replace_outermost(results, unique_core=2).unique_core,
          2,
      )
      self.assertEqual(
          unnest.replace_outermost(
              results, return_unused=True, unique_core=2, foo=3
          ),
          (FakeResults(2), {"foo": 3}),
      )
      self.assertRaises(
          ValueError,
          lambda: unnest.replace_innermost(  # pylint: disable=g-long-lambda
              results, unique_core=1, foo=1
          ),
      )
      self.assertRaises(
          ValueError,
          lambda: unnest.replace_outermost(  # pylint: disable=g-long-lambda
              results, unique_core=1, foo=1
          ),
      )
  
imports: import collections
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import unnest
label_desc: Use image node_id 5 for calling the TestNestedAccessors obj's underlying member method code with example usage: obj.test_flat_replace() without return types