code: def mocked_scope():
      # Code to acquire resource, e.g.:
      scope_mock = Mock()
      original_scope = pio._kaleido.scope
      pio._kaleido.scope = scope_mock
      try:
          yield scope_mock
      finally:
          pio._kaleido.scope = original_scope
  
file_path: plotly.py/packages/python/plotly/plotly/tests/test_optional/test_kaleido/test_kaleido.py
imports: import plotly.io
  import plotly.io.kaleido
  from contextlib import contextmanager
  from io import BytesIO
  from pathlib import Path
  from unittest.mock import Mock
label_desc: Use image node_id 2 for calling a global function with example usage: mocked_scope() without return types