code: def test_read_write_info(tmp_path):
      """Test IO of info."""
      info = read_info(raw_fname)
      temp_file = tmp_path / "info.fif"
      # check for bug `#1198`
      info["dev_head_t"]["trans"] = np.eye(4)
      t1 = info["dev_head_t"]["trans"]
      write_info(temp_file, info)
      info2 = read_info(temp_file)
      t2 = info2["dev_head_t"]["trans"]
      assert len(info["chs"]) == len(info2["chs"])
      assert_array_equal(t1, t2)
      # proc_history (e.g., GH#1875)
      creator = "é"
      info = read_info(chpi_fname)
      info["proc_history"][0]["creator"] = creator
      info["hpi_meas"][0]["creator"] = creator
      info["subject_info"]["his_id"] = creator
      info["subject_info"]["weight"] = 11.1
      info["subject_info"]["height"] = 2.3
  
      with info._unlock():
          if (
              info["gantry_angle"] is None
          ):  # future testing data may include it
              info["gantry_angle"] = 0.0  # Elekta supine position
      gantry_angle = info["gantry_angle"]
  
      meas_id = info["meas_id"]
      write_info(temp_file, info)
      info = read_info(temp_file)
      assert info["proc_history"][0]["creator"] == creator
      assert info["hpi_meas"][0]["creator"] == creator
      assert info["subject_info"]["his_id"] == creator
      assert info["gantry_angle"] == gantry_angle
      assert info["subject_info"]["height"] == 2.3
      assert info["subject_info"]["weight"] == 11.1
      for key in ["secs", "usecs", "version"]:
          assert info["meas_id"][key] == meas_id[key]
      assert_array_equal(info["meas_id"]["machid"], meas_id["machid"])
  
      # Test that writing twice produces the same file
      m1 = _empty_hash()
      with open(temp_file, "rb") as fid:
          m1.update(fid.read())
      m1 = m1.hexdigest()
      temp_file_2 = tmp_path / "info2.fif"
      assert temp_file_2 != temp_file
      write_info(temp_file_2, info)
      m2 = _empty_hash()
      with open(str(temp_file_2), "rb") as fid:
          m2.update(fid.read())
      m2 = m2.hexdigest()
      assert m1 == m2
  
      info = read_info(raw_fname)
      with info._unlock():
          info["meas_date"] = None
      anonymize_info(info, verbose="error")
      assert info["meas_date"] is None
      tmp_fname_3 = tmp_path / "info3.fif"
      write_info(tmp_fname_3, info)
      assert info["meas_date"] is None
      info2 = read_info(tmp_fname_3)
      assert info2["meas_date"] is None
  
      # Check that having a very old date in fine until you try to save it to fif
      with info._unlock(check_after=True):
          info["meas_date"] = datetime(
              1800, 1, 1, 0, 0, 0, tzinfo=timezone.utc
          )
      fname = tmp_path / "test.fif"
      with pytest.raises(RuntimeError, match="must be between "):
          write_info(fname, info)
  
imports: import pickle
  import string
  from datetime import date, datetime, timedelta, timezone
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from mne import Annotations, Epochs, compute_covariance, make_forward_solution, make_sphere_model, pick_info, pick_types, read_cov, read_epochs, read_events, read_evokeds, read_forward_solution, setup_volume_source_space, write_cov, write_forward_solution
  from mne._fiff import meas_info
  from mne._fiff._digitization import DigPoint, _make_dig_points
  from mne._fiff.constants import FIFF
  from mne._fiff.meas_info import RAW_INFO_FIELDS, Info, MNEBadsList, _add_timedelta_to_stamp, _bad_chans_comp, _dt_to_stamp, _force_update_info, _get_valid_units, _merge_info, _read_extended_ch_info, _stamp_to_dt, anonymize_info, create_info, read_fiducials, read_info, write_fiducials, write_info
  from mne._fiff.proj import Projection
  from mne._fiff.tag import _coil_trans_to_loc, _loc_to_coil_trans
  from mne._fiff.write import DATE_NONE, _generate_meas_id
  from mne.channels import equalize_channels, make_standard_montage, read_polhemus_fastscan
  from mne.datasets import testing
  from mne.event import make_fixed_length_events
  from mne.io import BaseRaw, RawArray, read_raw_ctf, read_raw_fif
  from mne.minimum_norm import apply_inverse, make_inverse_operator, read_inverse_operator, write_inverse_operator
  from mne.transforms import Transform
  from mne.utils import _empty_hash, _record_warnings, assert_object_equal, catch_logging
label_desc: Use image node_id 8 for calling a global function with example usage: test_read_write_info(tmp_path) without return types