code: def test_image_screenshot(
      renderer_interactive_pyvistaqt,
      tmp_path,
      pixel_ratio,
      brain_gc,
  ):
      """Test screenshot and image saving."""
      size = (300, 300)
      brain = _create_testing_brain(
          hemi="rh", show_traces=False, size=size
      )
      azimuth, elevation = 180.0, 90.0
      fname = tmp_path / "test.png"
      assert not fname.is_file()
      brain.save_image(fname)
      assert fname.is_file()
      fp = np.array(
          brain._renderer.figure.plotter.renderer.ComputeVisiblePropBounds()
      )
      fp = (fp[1::2] + fp[::2]) * 0.5
      for view_args in (
          dict(azimuth=azimuth, elevation=elevation, focalpoint="auto"),
          dict(view="lateral", hemi="rh"),
      ):
          brain.show_view(**view_args)
          _, _, a_, e_, f_ = brain.get_view()
          assert_allclose(a_, azimuth, atol=1e-6)
          assert_allclose(e_, elevation)
          assert_allclose(f_, fp, atol=1e-6)
      img = brain.screenshot(mode="rgba")
      want_size = np.array(
          [size[0] * pixel_ratio, size[1] * pixel_ratio, 4]
      )
      # on macOS sometimes matplotlib is HiDPI and VTK is not...
      div = (
          2
          if np.allclose(img.shape[:2], want_size[:2] / 2.0, atol=15)
          else 1
      )
      want_size[:2] /= div
      assert_allclose(img.shape, want_size, atol=15)
      brain.close()
  
imports: import os
  import platform
  from pathlib import Path
  from shutil import copyfile
  import numpy
  import pytest
  from matplotlib import image
  from matplotlib.lines import Line2D
  from numpy.testing import assert_allclose, assert_array_equal
  from mne import Dipole, MixedSourceEstimate, SourceEstimate, VolSourceEstimate, create_info, pick_types_forward, read_cov, read_evokeds, read_forward_solution, read_source_estimate, vertex_to_mni, write_surface
  from mne.channels import make_dig_montage
  from mne.datasets import testing
  from mne.io import read_info
  from mne.label import read_label
  from mne.minimum_norm import apply_inverse, make_inverse_operator
  from mne.source_estimate import _BaseSourceEstimate
  from mne.source_space import read_source_spaces, setup_volume_source_space
  from mne.utils import check_version
  from mne.viz import ui_events
  from mne.viz._brain import Brain, _BrainScraper, _LayeredMesh, _LinkViewer
  from mne.viz._brain.colormap import calculate_lut
  from mne.viz.utils import _get_cmap
label_desc: Use image node_id 8 for calling a global function with example usage: test_image_screenshot(renderer_interactive_pyvistaqt, tmp_path, pixel_ratio, brain_gc) without return types