<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def savefig(path, fig=None, close=True, *, dpi=300):
 """Save a figure. Parameters path : str Path to save figure at. fig : matplotlib.figure.Figure object (optional) The figure to plot onto. If None, gets current figure. Default is None. close : bool (optional) Toggle closing of figure after saving. Default is True. Returns ------- str The full path where the figure was saved. """

    # get fig
    if fig is None:
        fig = plt.gcf()
    # get full path
    path = os.path.abspath(path)
    # save
    plt.savefig(path, dpi=dpi, transparent=False, pad_inches=1, facecolor="none")
    # close
    if close:
        plt.close(fig)
    # finish
    return path