code: def _parse_impedance(settings, recording_date=None):
      """Parse impedances from the header file.
  
      Parameters
      ----------
      settings : list
          The header settings lines from the VHDR/AHDR file.
      recording_date : datetime.datetime | None
          The date of the recording as extracted from the VMRK/AMRK file.
  
      Returns
      -------
      impedances : dict
          A dictionary of all electrodes and their impedances.
      """
      ranges = _parse_impedance_ranges(settings)
      impedance_setting_lines = [
          i
          for i in settings
          if i.startswith("Impedance [") and i.endswith(" :")
      ]
      impedances = dict()
      if len(impedance_setting_lines) > 0:
          idx = settings.index(impedance_setting_lines[0])
          impedance_setting = impedance_setting_lines[0].split()
          impedance_unit = impedance_setting[1].lstrip("[").rstrip("]")
          impedance_time = None
  
          # If we have a recording date, we can update it with the time of
          # impedance measurement
          if recording_date is not None:
              meas_time = [
                  int(i) for i in impedance_setting[3].split(":")
              ]
              impedance_time = recording_date.replace(
                  hour=meas_time[0],
                  minute=meas_time[1],
                  second=meas_time[2],
                  microsecond=0,
              )
          for setting in settings[idx + 1 :]:
              # Parse channel impedances until we find a line that doesn't start
              # with a channel name and optional +/- polarity for passive elecs
              match = re.match(r"[ a-zA-Z0-9_+-]+:", setting)
              if match:
                  channel_name = match.group().rstrip(":")
                  channel_imp_line = setting.split()
                  imp_as_number = re.findall(
                      r"[-+]?\d*\.\d+|\d+", channel_imp_line[-1]
                  )
                  channel_impedance = dict(
                      imp=float(imp_as_number[0])
                      if imp_as_number
                      else np.nan,
                      imp_unit=impedance_unit,
                  )
                  if impedance_time is not None:
                      channel_impedance.update(
                          {"imp_meas_time": impedance_time}
                      )
  
                  if channel_name == "Ref" and "Reference" in ranges:
                      channel_impedance.update(ranges["Reference"])
                  elif channel_name == "Gnd" and "Ground" in ranges:
                      channel_impedance.update(ranges["Ground"])
                  elif "Data" in ranges:
                      channel_impedance.update(ranges["Data"])
                  impedances[channel_name] = channel_impedance
              else:
                  break
      return impedances
  
imports: import configparser
  import os
  import os.path
  import re
  from datetime import datetime, timezone
  from io import StringIO
  import numpy
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.utils import _mult_cal_one, _read_segments_file
  from ...annotations import Annotations, read_annotations
  from ...channels import make_dig_montage
  from ...defaults import HEAD_SIZE_DEFAULT
  from ...transforms import _sph_to_cart
  from ...utils import _DefaultEventParser, fill_doc, logger, verbose, warn
  from ..base import BaseRaw
label_desc: Use image node_id 10 for calling a global function with example usage: _parse_impedance(settings, recording_date) and returns: impedances