code: def test_get_nested_obj(self):
      class Nest:
          __nested_attrs__ = ("inner1", "inner2")
  
          def __init__(self, inner1, inner2, inner3):
              self.inner1 = inner1
              self.inner2 = inner2
              self.inner3 = inner3
  
      nest = Nest("x", "y", "z")
  
      # Search stops if `nested_key` is found.
      self.assertEqual(
          unnest.get_nested_objs(
              nest,
              nested_key="__nested_attrs__",
              fallback_attrs=("inner1", "inner2", "inner3"),
          ),
          [("inner1", "x"), ("inner2", "y")],
      )
  
      # If `nested_key` is not found, search in all of `fallback_attrs`.
      self.assertEqual(
          unnest.get_nested_objs(
              nest,
              nested_key="does_not_exist",
              fallback_attrs=("inner1", "inner2", "inner3"),
          ),
          [("inner1", "x"), ("inner2", "y"), ("inner3", "z")],
      )
  
      # If nothing is found, empty list is returned.
      self.assertEqual(
          unnest.get_nested_objs(
              nest,
              nested_key="does_not_exist",
              fallback_attrs=("does_not_exist"),
          ),
          [],
      )
  
      # `getattr(obj, nested_key)` and `fallback_attrs` can be either strings or
      # collections of strings.
      nest2 = Nest("x", "y", "z")
      nest2.__nested_attrs__ = "inner3"
      self.assertEqual(
          unnest.get_nested_objs(
              nest2,
              nested_key="__nested_attrs__",
              fallback_attrs=("inner1", "inner2"),
          ),
          [("inner3", "z")],
      )
      self.assertEqual(
          unnest.get_nested_objs(
              nest2,
              nested_key="does_not_exist",
              fallback_attrs="inner2",
          ),
          [("inner2", "y")],
      )
  
imports: import collections
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import unnest
label_desc: Use image node_id 9 for calling the TestNestedAccessors obj's underlying member method code with example usage: obj.test_get_nested_obj() without return types