code: def test_keep_alive_constructor(capture):
      n_inst = ConstructorStats.detail_reg_inst()
  
      with capture:
          p = m.Parent(m.Child())
          assert ConstructorStats.detail_reg_inst() == n_inst + 2
      assert (
          capture
          == """
          Allocating child.
          Allocating parent.
      """
      )
      with capture:
          del p
          assert ConstructorStats.detail_reg_inst() == n_inst
      assert (
          capture
          == """
          Releasing parent.
          Releasing child.
      """
      )
  
file_path: coremltools/deps/pybind11/tests/test_call_policies.py
imports: import pytest
  import env
  from pybind11_tests import ConstructorStats
  from pybind11_tests import call_policies
label_desc: Use image node_id 7 for calling a global function with example usage: test_keep_alive_constructor(capture) without return types