code: def test_constrained_toggle():
      fig, ax = plt.subplots()
      with pytest.warns(PendingDeprecationWarning):
          fig.set_constrained_layout(True)
          assert fig.get_constrained_layout()
          fig.set_constrained_layout(False)
          assert not fig.get_constrained_layout()
          fig.set_constrained_layout(True)
          assert fig.get_constrained_layout()
  
imports: import gc
  import numpy
  import pytest
  import matplotlib
  from matplotlib.testing.decorators import image_comparison
  import matplotlib.pyplot
  import matplotlib.transforms
  from matplotlib import gridspec, ticker
label_desc: Use image node_id 44 for calling a global function with example usage: test_constrained_toggle() without return types