def save_figures(filename, fig_IDs=None, **kwargs):
import matplotlib.pyplot as plt<EOL>if(fig_IDs is not None):<EOL><INDENT>if(type(fig_IDs) is list):<EOL><INDENT>savetype = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>savetype = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>savetype = '<STR_LIT>'<EOL><DEDENT>if(savetype == '<STR_LIT>'):<EOL><INDENT>from matplotlib.backends.backend_pdf import PdfPages<EOL>if(len(filename.split('<STR_LIT:.>')) == <NUM_LIT:1>):<EOL><INDENT>filename = filename + '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>filename = '<STR_LIT:.>'.join(filename.split('<STR_LIT:.>')[:-<NUM_LIT:1>])+'<STR_LIT>'<EOL><DEDENT>pdf = PdfPages(filename)<EOL>if fig_IDs is None:<EOL><INDENT>figs = [plt.figure(n) for n in plt.get_fignums()]<EOL><DEDENT>else:<EOL><INDENT>figs = [plt.figure(n) for n in fig_IDs]<EOL><DEDENT>for fig in figs:<EOL><INDENT>fig.savefig(pdf, format='<STR_LIT>', **kwargs)<EOL><DEDENT>pdf.close()<EOL><DEDENT>elif(savetype == '<STR_LIT>'):<EOL><INDENT>plt.figure(fig_IDs).savefig(filename, **kwargs)<EOL><DEDENT>
Save figures.

Parameters
----------
filename - str
    Name of output file

fig_IDs - int, numpy.array, list, optional, default None
    A list of open figure IDs or a figure ID that will be saved to a
    pdf/png file respectively.

**kwargs - 
    Extra keyword arguments passed into 'matplotlib.pyplot.savefig'.