code: def start_and_end_file(fname, id_=None):
      """Start and (if successfully written) close the file."""
      with start_file(fname, id_=id_) as fid:
          yield fid
          end_file(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 27 for calling a global function with example usage: start_and_end_file(fname, id_) without return types