code: def test_crop_by_annotations(meas_date, first_samp):
      """Test crop by annotations of raw."""
      raw = read_raw_fif(raw_fname)
  
      if meas_date is None:
          raw.set_meas_date(None)
  
      raw = mne.io.RawArray(
          raw.get_data(), raw.info, first_samp=first_samp
      )
  
      onset = np.array([0, 1.5], float)
      if meas_date is not None:
          onset += raw.first_time
      annot = mne.Annotations(
          onset=onset,
          duration=[1, 0.5],
          description=["a", "b"],
          orig_time=raw.info["meas_date"],
      )
  
      raw.set_annotations(annot)
      raws = raw.crop_by_annotations()
      assert len(raws) == 2
      assert len(raws[0].annotations) == 1
      assert raws[0].times[-1] == pytest.approx(
          annot[:1].duration[0], rel=1e-3
      )
      assert raws[0].annotations.description[0] == annot.description[0]
      assert len(raws[1].annotations) == 1
      assert raws[1].times[-1] == pytest.approx(
          annot[1:2].duration[0], rel=5e-3
      )
      assert raws[1].annotations.description[0] == annot.description[1]
  
imports: import math
  import os
  import re
  from contextlib import redirect_stdout
  from io import StringIO
  from os import path
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less
  import mne
  from mne import Annotations, concatenate_raws, create_info, pick_types
  from mne._fiff._digitization import DigPoint, _dig_kind_dict
  from mne._fiff.constants import FIFF
  from mne._fiff.meas_info import Info, _get_valid_units, _writing_info_hdf5
  from mne._fiff.pick import _ELECTRODE_CH_TYPES, _FNIRS_CH_TYPES_SPLIT
  from mne._fiff.proj import Projection
  from mne._fiff.utils import _mult_cal_one
  from mne.fixes import _numpy_h5py_dep
  from mne.io import BaseRaw, RawArray, read_raw_fif
  from mne.io.base import _get_scaling
  from mne.transforms import Transform
  from mne.utils import _import_h5io_funcs, _raw_annot, _stamp_to_dt, _TempDir, catch_logging, check_version, object_diff
label_desc: Use image node_id 8 for calling a global function with example usage: test_crop_by_annotations(meas_date, first_samp) without return types