code: def start_file(fname, id_=None):
      """Open a fif file for writing and writes the compulsory header tags.
  
      Parameters
      ----------
      fname : path-like | fid
          The name of the file to open. It is recommended
          that the name ends with .fif or .fif.gz. Can also be an
          already opened file.
      id_ : dict | None
          ID to use for the FIFF_FILE_ID.
      """
      if _file_like(fname):
          logger.debug("Writing using %s I/O" % type(fname))
          fid = fname
          fid.seek(0)
      else:
          fname = str(fname)
          if op.splitext(fname)[1].lower() == ".gz":
              logger.debug("Writing using gzip")
              # defaults to compression level 9, which is barely smaller but much
              # slower. 2 offers a good compromise.
              fid = GzipFile(fname, "wb", compresslevel=2)
          else:
              logger.debug("Writing using normal I/O")
              fid = open(fname, "wb")
      #   Write the compulsory items
      write_id(fid, FIFF.FIFF_FILE_ID, id_)
      write_int(fid, FIFF.FIFF_DIR_POINTER, -1)
      write_int(fid, FIFF.FIFF_FREE_LIST, -1)
      return fid
  
imports: import os.path
  import re
  import time
  import uuid
  from contextlib import contextmanager
  from gzip import GzipFile
  import numpy
  from scipy.sparse import csc_matrix, csr_matrix
  from ..utils import _file_like, _validate_type, logger
  from ..utils.numerics import _cal_to_julian
  from .constants import FIFF
label_desc: Use image node_id 26 for calling a global function with example usage: start_file(fname, id_) and returns: fid