code: def export_model(self, format, file_name=None):
          
          # Handle SBGN as special case
          if format == 'sbgn':
              exp_str = export_sbgn(self.model)
          elif format == 'kappa_im':
              # NOTE: this export is not a str, rather a graph object
              return export_kappa_im(self.model, file_name)
          elif format == 'kappa_cm':
              # NOTE: this export is not a str, rather a graph object
              return export_kappa_cm(self.model, file_name)
          else:
              try:
                  exp_str = pysb.export.export(self.model, format)
              except KeyError:
                  logging.error('Unknown export format: %s' % format)
                  return None
  
          if file_name:
              with open(file_name, 'wb') as fh:
                  fh.write(exp_str.encode('utf-8'))
          return exp_str
docs: Save the assembled model in a modeling formalism other than PySB.
  
          For more details on exporting PySB models, see
          http://pysb.readthedocs.io/en/latest/modules/export/index.html
  
          Parameters
          ----------
          format : str
              The format to export into, for instance "kappa", "bngl",
              "sbml", "matlab", "mathematica", "potterswheel". See
              http://pysb.readthedocs.io/en/latest/modules/export/index.html
              for a list of supported formats. In addition to the formats
              supported by PySB itself, this method also provides "sbgn"
              output.
  
          file_name : Optional[str]
              An optional file name to save the exported model into.
  
          Returns
          -------
          exp_str : str or object
              The exported model string or object