code: def test_io(tmp_path):
      """Test TFR IO capacities."""
      pd = pytest.importorskip("pandas")
      pytest.importorskip("h5io")
  
      fname = tmp_path / "test-tfr.h5"
      data = np.zeros((3, 2, 3))
      times = np.array([0.1, 0.2, 0.3])
      freqs = np.array([0.10, 0.20])
  
      info = mne.create_info(
          ["MEG 001", "MEG 002", "MEG 003"],
          1000.0,
          ["mag", "mag", "mag"],
      )
      with info._unlock(check_after=True):
          info["meas_date"] = datetime.datetime(
              year=2020, month=2, day=5, tzinfo=datetime.timezone.utc
          )
      tfr = AverageTFR(
          info,
          data=data,
          times=times,
          freqs=freqs,
          nave=20,
          comment="test",
          method="crazy-tfr",
      )
      tfr.save(fname)
      tfr2 = read_tfrs(fname, condition="test")
      assert isinstance(tfr2.info, Info)
      assert isinstance(tfr2.info["dev_head_t"], Transform)
  
      assert_array_equal(tfr.data, tfr2.data)
      assert_array_equal(tfr.times, tfr2.times)
      assert_array_equal(tfr.freqs, tfr2.freqs)
      assert_equal(tfr.comment, tfr2.comment)
      assert_equal(tfr.nave, tfr2.nave)
  
      pytest.raises(OSError, tfr.save, fname)
  
      tfr.comment = None
      # test old meas_date
      with info._unlock():
          info["meas_date"] = (1, 2)
      tfr.save(fname, overwrite=True)
      assert_equal(read_tfrs(fname, condition=0).comment, tfr.comment)
      tfr.comment = "test-A"
      tfr2.comment = "test-B"
  
      fname = tmp_path / "test2-tfr.h5"
      write_tfrs(fname, [tfr, tfr2])
      tfr3 = read_tfrs(fname, condition="test-A")
      assert_equal(tfr.comment, tfr3.comment)
  
      assert isinstance(tfr.info, mne.Info)
  
      tfrs = read_tfrs(fname, condition=None)
      assert_equal(len(tfrs), 2)
      tfr4 = tfrs[1]
      assert_equal(tfr2.comment, tfr4.comment)
  
      pytest.raises(ValueError, read_tfrs, fname, condition="nonono")
      # Test save of EpochsTFR.
      n_events = 5
      data = np.zeros((n_events, 3, 2, 3))
  
      # create fake metadata
      rng = np.random.RandomState(42)
      rt = np.round(rng.uniform(size=(n_events,)), 3)
      trialtypes = np.array(["face", "place"])
      trial = trialtypes[
          (rng.uniform(size=(n_events,)) > 0.5).astype(int)
      ]
      meta = pd.DataFrame(dict(RT=rt, Trial=trial))
      # fake events and event_id
      events = np.zeros([n_events, 3])
      events[:, 0] = np.arange(n_events)
      events[:, 2] = np.ones(n_events)
      event_id = {"a/b": 1}
      # fake selection
      n_dropped_epochs = 3
      selection = np.arange(n_events + n_dropped_epochs)[
          n_dropped_epochs:
      ]
      drop_log = tuple(
          [("IGNORED",) for i in range(n_dropped_epochs)]
          + [() for i in range(n_events)]
      )
  
      tfr = EpochsTFR(
          info,
          data=data,
          times=times,
          freqs=freqs,
          comment="test",
          method="crazy-tfr",
          events=events,
          event_id=event_id,
          selection=selection,
          drop_log=drop_log,
          metadata=meta,
      )
      fname_save = fname
      tfr.save(fname_save, True)
      fname_write = tmp_path / "test3-tfr.h5"
      write_tfrs(fname_write, tfr, overwrite=True)
      for fname in [fname_save, fname_write]:
          read_tfr = read_tfrs(fname)[0]
          assert_array_equal(tfr.data, read_tfr.data)
          assert_metadata_equal(tfr.metadata, read_tfr.metadata)
          assert_array_equal(tfr.events, read_tfr.events)
          assert tfr.event_id == read_tfr.event_id
          assert_array_equal(tfr.selection, read_tfr.selection)
          assert tfr.drop_log == read_tfr.drop_log
      with pytest.raises(
          NotImplementedError, match="condition not supported"
      ):
          tfr = read_tfrs(fname, condition="a")
  
imports: import datetime
  import re
  from itertools import product
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from scipy.signal import morlet2
  import mne
  from mne import Epochs, EpochsArray, Info, Transform, create_info, pick_types, read_events
  from mne.io import read_raw_fif
  from mne.tests.test_epochs import assert_metadata_equal
  from mne.time_frequency import tfr_array_morlet, tfr_array_multitaper
  from mne.time_frequency.tfr import AverageTFR, EpochsTFR, _compute_tfr, _make_dpss, combine_tfr, cwt, fwhm, morlet, read_tfrs, tfr_morlet, tfr_multitaper, write_tfrs
  from mne.utils import catch_logging, grand_average
  from mne.viz.utils import _fake_click, _fake_keypress, _fake_scroll
label_desc: Use image node_id 8 for calling a global function with example usage: test_io(tmp_path) without return types