code: def save_sbml(filename, model, y0=None, volume=1.0, is_valid=True):
      
      y0 = y0 or {}
  
      import libsbml
  
      document = export_sbml(model, y0, volume, is_valid)
  
      # with open(filename, 'w') as fout:
      #     fout.write(libsbml.writeSBMLToString(document))
      # writer = libsbml.SBMLWriter()
      # writer.writeSBML(document, filename)
      libsbml.writeSBML(document, filename)
docs: Save a model in the SBML format.
  
      Parameters
      ----------
      model : NetworkModel
      y0 : dict
          Initial condition.
      volume : Real or Real3, optional
          A size of the simulation volume.
      is_valid : bool, optional
          Check if the generated model is valid. True as a default.