<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_note(note, **kwargs):
 """ Add a new note """

    note_i = Note()
    note_i.ref_key = note.ref_key

    note_i.set_ref(note.ref_key, note.ref_id)

    note_i.value = note.value

    note_i.created_by = kwargs.get('user_id')

    db.DBSession.add(note_i)
    db.DBSession.flush()

    return note_i