code: def test_anonymize(tmp_path):
      """Test that sensitive information can be anonymized."""
      pytest.raises(TypeError, anonymize_info, "foo")
  
      # Fake some subject data
      raw = read_raw_fif(raw_fname)
      raw.set_annotations(
          Annotations(
              onset=[0, 1],
              duration=[1, 1],
              description="dummy",
              orig_time=None,
          )
      )
      first_samp = raw.first_samp
      expected_onset = np.arange(2) + raw._first_time
      assert raw.first_samp == first_samp
      assert_allclose(raw.annotations.onset, expected_onset)
  
      # test mne.anonymize_info()
      events = read_events(event_name)
      epochs = Epochs(raw, events[:1], 2, 0.0, 0.1, baseline=None)
      _test_anonymize_info(raw.info.copy())
      _test_anonymize_info(epochs.info.copy())
  
      # test instance methods & I/O roundtrip
      for inst, keep_his in zip((raw, epochs), (True, False)):
          inst = inst.copy()
  
          subject_info = dict(his_id="Volunteer", sex=2, hand=1)
          inst.info["subject_info"] = subject_info
          inst.anonymize(keep_his=keep_his)
  
          si = inst.info["subject_info"]
          if keep_his:
              assert si == subject_info
          else:
              assert si["his_id"] == "0"
              assert si["sex"] == 0
              assert "hand" not in si
  
          # write to disk & read back
          inst_type = "raw" if isinstance(inst, BaseRaw) else "epo"
          fname = "tmp_raw.fif" if inst_type == "raw" else "tmp_epo.fif"
          out_path = tmp_path / fname
          inst.save(out_path, overwrite=True)
          if inst_type == "raw":
              read_raw_fif(out_path)
          else:
              read_epochs(out_path)
  
      # test that annotations are correctly zeroed
      raw.anonymize()
      assert raw.first_samp == first_samp
      assert_allclose(raw.annotations.onset, expected_onset)
      assert raw.annotations.orig_time == raw.info["meas_date"]
      stamp = _dt_to_stamp(raw.info["meas_date"])
      assert raw.annotations.orig_time == _stamp_to_dt(stamp)
  
      with raw.info._unlock():
          raw.info["meas_date"] = None
      raw.anonymize(daysback=None)
      with pytest.warns(RuntimeWarning, match="None"):
          raw.anonymize(daysback=123)
      assert raw.annotations.orig_time is None
      assert raw.first_samp == first_samp
      assert_allclose(raw.annotations.onset, expected_onset)
  
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 18 for calling a global function with example usage: test_anonymize(tmp_path) without return types