code: def _extract_sampling_rate(dat):
      """Extract the sample rate from the time field."""
      # This is a workaround to provide support for Artinis data.
      # It allows for a 1% variation in the sampling times relative
      # to the average sampling rate of the file.
      MAXIMUM_ALLOWED_SAMPLING_JITTER_PERCENTAGE = 1.0
  
      time_data = np.array(dat.get("nirs/data1/time"))
      sampling_rate = 0
      if len(time_data) == 2:
          # specified as onset, samplerate
          sampling_rate = 1.0 / (time_data[1] - time_data[0])
      else:
          # specified as time points
          periods = np.diff(time_data)
          uniq_periods = np.unique(periods.round(decimals=4))
          if uniq_periods.size == 1:
              # Uniformly sampled data
              sampling_rate = 1.0 / uniq_periods.item()
          else:
              # Hopefully uniformly sampled data with some precision issues.
              # This is a workaround to provide support for Artinis data.
              mean_period = np.mean(periods)
              sampling_rate = 1.0 / mean_period
              ideal_times = np.linspace(
                  time_data[0], time_data[-1], time_data.size
              )
              max_jitter = np.max(np.abs(time_data - ideal_times))
              percent_jitter = 100.0 * max_jitter / mean_period
              msg = (
                  f"Found jitter of {percent_jitter:3f}% in sample times. Sampling "
                  f"rate has been set to {sampling_rate:1f}."
              )
              if (
                  percent_jitter
                  > MAXIMUM_ALLOWED_SAMPLING_JITTER_PERCENTAGE
              ):
                  warn(
                      f"{msg} Note that MNE-Python does not currently support SNIRF "
                      "files with non-uniformly-sampled data."
                  )
              else:
                  logger.info(msg)
      time_unit = _get_metadata_str(dat, "TimeUnit")
      time_unit_scaling = _get_timeunit_scaling(time_unit)
      sampling_rate *= time_unit_scaling
  
      return sampling_rate
  
imports: import datetime
  import re
  import numpy
  from ..._fiff._digitization import _make_dig_points
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _format_dig_points, create_info
  from ..._fiff.utils import _mult_cal_one
  from ..._freesurfer import get_mni_fiducials
  from ...annotations import Annotations
  from ...transforms import _frame_to_str, apply_trans
  from ...utils import _check_fname, _import_h5py, fill_doc, logger, verbose, warn
  from ..base import BaseRaw
  from ..nirx.nirx import _convert_fnirs_to_head
label_desc: Use image node_id 6 for calling a global function with example usage: _extract_sampling_rate(dat) and returns: sampling_rate