code: def test_render_report(renderer_pyvistaqt, tmp_path, invisible_fig):
      """Test rendering *.fif files for mne report."""
      pytest.importorskip("pymatreader")
  
      raw_fname_new = tmp_path / "temp_raw.fif"
      raw_fname_new_bids = tmp_path / "temp_meg.fif"
      ms_fname_new = tmp_path / "temp_ms_raw.fif"
      event_fname_new = tmp_path / "temp_raw-eve.fif"
      cov_fname_new = tmp_path / "temp_raw-cov.fif"
      proj_fname_new = tmp_path / "temp_ecg-proj.fif"
      fwd_fname_new = tmp_path / "temp_raw-fwd.fif"
      inv_fname_new = tmp_path / "temp_raw-inv.fif"
      nirs_fname_new = tmp_path / "temp_raw-nirs.snirf"
      for a, b in [
          [raw_fname, raw_fname_new],
          [raw_fname, raw_fname_new_bids],
          [ms_fname, ms_fname_new],
          [events_fname, event_fname_new],
          [cov_fname, cov_fname_new],
          [ecg_proj_fname, proj_fname_new],
          [fwd_fname, fwd_fname_new],
          [inv_fname, inv_fname_new],
          [nirs_fname, nirs_fname_new],
      ]:
          shutil.copyfile(a, b)
  
      # create and add -epo.fif and -ave.fif files
      epochs_fname = tmp_path / "temp-epo.fif"
      evoked_fname = tmp_path / "temp-ave.fif"
      # Speed it up by picking channels
      raw = read_raw_fif(raw_fname_new)
      raw.pick(["MEG 0111", "MEG 0121", "EEG 001", "EEG 002"])
      raw.del_proj()
      raw.set_eeg_reference(projection=True).load_data()
      epochs = Epochs(raw, read_events(events_fname), 1, -0.2, 0.2)
      epochs.save(epochs_fname, overwrite=True)
      # This can take forever, so let's make it fast
      # Also, make sure crop range is wide enough to avoid rendering bug
      evoked = epochs.average()
      with pytest.warns(
          RuntimeWarning, match="tmax is not in time interval"
      ):
          evoked.crop(0.1, 0.2)
      evoked.save(evoked_fname)
  
      report = Report(
          info_fname=raw_fname_new,
          subjects_dir=subjects_dir,
          projs=False,
          image_format="png",
      )
      with pytest.warns(RuntimeWarning, match="Cannot render MRI"):
          report.parse_folder(
              data_path=tmp_path,
              on_error="raise",
              n_time_points_evokeds=2,
              raw_butterfly=False,
              stc_plot_kwargs=stc_plot_kwargs,
              topomap_kwargs=topomap_kwargs,
          )
      assert repr(report)
  
      # Check correct paths and filenames
      fnames = glob.glob(str(tmp_path / "*.fif"))
      fnames.extend(glob.glob(str(tmp_path / "*.snirf")))
  
      titles = [
          Path(x).name for x in fnames if not x.endswith("-ave.fif")
      ]
      titles.append(f"{evoked_fname.name}: {evoked.comment}")
  
      _, _, content_titles, _ = report._content_as_html()
      for title in titles:
          assert title in content_titles
          assert "".join(report.html).find(title) != -1
  
      assert len(content_titles) == len(fnames)
  
      # Check saving functionality
      report.data_path = tmp_path
      fname = tmp_path / "report.html"
      report.save(fname=fname, open_browser=False)
      assert fname.is_file()
      html = fname.read_text(encoding="utf-8")
      # Evoked in `evoked_fname`
      assert f"{evoked_fname.name}: {evoked.comment}" in html
      assert "Topographies" in html
      assert "Global field power" in html
  
      # Check saving same report to new filename
      report.save(fname=tmp_path / "report2.html", open_browser=False)
      assert (tmp_path / "report2.html").is_file()
  
      # Check overwriting file
      report.save(
          fname=tmp_path / "report.html",
          open_browser=False,
          overwrite=True,
      )
      assert (tmp_path / "report.html").is_file()
  
      # Check pattern matching with multiple patterns
      pattern = ["*proj.fif", "*eve.fif"]
      with pytest.warns(RuntimeWarning, match="Cannot render MRI"):
          report.parse_folder(
              data_path=tmp_path, pattern=pattern, raw_butterfly=False
          )
      assert repr(report)
  
      fnames = glob.glob(str(tmp_path / "*.raw")) + glob.glob(
          str(tmp_path / "*.raw")
      )
  
      content_names = [element.name for element in report._content]
      for fname in fnames:
          fname = Path(fname)
          assert fname.name in [Path(x).name for x in content_names]
          assert "".join(report.html).find(fname.name) != -1
  
      with pytest.raises(ValueError, match="Invalid value"):
          Report(image_format="foo")
      with pytest.raises(ValueError, match="Invalid value"):
          Report(image_format=None)
  
      # ndarray support smoke test
      report.add_figure(fig=np.zeros((2, 3, 3)), title="title")
  
      with pytest.raises(TypeError, match="It seems you passed a path"):
          report.add_figure(fig="foo", title="title")
      with pytest.raises(
          TypeError, match=".*MNEQtBrowser.*Figure3D.*got.*"
      ):
          report.add_figure(fig=1.0, title="title")
  
imports: import base64
  import copy
  import glob
  import os
  import pickle
  import re
  import shutil
  from io import BytesIO
  from pathlib import Path
  import numpy
  import pytest
  from matplotlib import pyplot
  from mne import Epochs, create_info, pick_channels_cov, read_cov, read_events, read_evokeds
  from mne._fiff.write import DATE_NONE
  from mne.datasets import testing
  from mne.epochs import make_metadata
  from mne.io import RawArray, read_info, read_raw_fif
  from mne.preprocessing import ICA
  from mne.report import Report, _ReportScraper, open_report, report
  from mne.report import report
  from mne.report.report import _ALLOWED_IMAGE_FORMATS, CONTENT_ORDER, _webp_supported
  from mne.utils import Bunch
  from mne.utils._testing import assert_object_equal
  from mne.viz import plot_alignment
label_desc: Use image node_id 3 for calling a global function with example usage: test_render_report(renderer_pyvistaqt, tmp_path, invisible_fig) without return types