code: def test_keep_alive_return_value(capture):
      from pybind11_tests import Parent
  
      with capture:
          p = Parent()
      assert capture == "Allocating parent."
      with capture:
          p.returnChild()
          pytest.gc_collect()
      assert (
          capture
          == """
          Allocating child.
          Releasing child.
      """
      )
      with capture:
          del p
          pytest.gc_collect()
      assert capture == "Releasing parent."
  
      with capture:
          p = Parent()
      assert capture == "Allocating parent."
      with capture:
          p.returnChildKeepAlive()
          pytest.gc_collect()
      assert capture == "Allocating child."
      with capture:
          del p
          pytest.gc_collect()
      assert (
          capture
          == """
          Releasing parent.
          Releasing child.
      """
      )
  
imports: import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: test_keep_alive_return_value(capture) without return types