code: def test_deeply_nested_replace(self):
      results = _build_deeply_nested(0, 1, 2, 3, 4)
      self.assertTrue(
          unnest.replace_innermost(results, unique_nesting=5),
          _build_deeply_nested(0, 1, 2, 5, 4),
      )
      self.assertTrue(
          unnest.replace_outermost(results, unique_nesting=5),
          _build_deeply_nested(5, 1, 2, 3, 4),
      )
      self.assertTrue(
          unnest.replace_innermost(results, unique_atypical_nesting=5),
          _build_deeply_nested(0, 1, 5, 3, 4),
      )
      self.assertTrue(
          unnest.replace_outermost(results, unique_atypical_nesting=5),
          _build_deeply_nested(0, 5, 2, 3, 4),
      )
      self.assertTrue(
          unnest.replace_innermost(results, unique_core=5),
          _build_deeply_nested(0, 1, 2, 3, 5),
      )
      self.assertTrue(
          unnest.replace_outermost(results, unique_core=5),
          _build_deeply_nested(0, 1, 2, 3, 5),
      )
      self.assertTrue(
          unnest.replace_innermost(
              results,
              unique_nesting=5,
              unique_atypical_nesting=6,
              unique_core=7,
          ),
          _build_deeply_nested(0, 1, 6, 5, 7),
      )
      self.assertTrue(
          unnest.replace_innermost(
              results,
              return_unused=True,
              unique_nesting=5,
              unique_atypical_nesting=6,
              unique_core=7,
              foo=8,
          ),
          (_build_deeply_nested(0, 1, 6, 5, 7), {"foo": 8}),
      )
      self.assertTrue(
          unnest.replace_outermost(
              results,
              unique_nesting=5,
              unique_atypical_nesting=6,
              unique_core=7,
          ),
          _build_deeply_nested(5, 6, 2, 3, 7),
      )
      self.assertTrue(
          unnest.replace_outermost(
              results,
              return_unused=True,
              unique_nesting=5,
              unique_atypical_nesting=6,
              unique_core=7,
              foo=8,
          ),
          (_build_deeply_nested(5, 6, 2, 3, 7), {"foo": 8}),
      )
      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 8 for calling the TestNestedAccessors obj's underlying member method code with example usage: obj.test_deeply_nested_replace() without return types