def convert_tvars_to_dict(tvars, name2nparr=None):
    """
    convert the input training variables to a dictionary

    :param tvars: the tensorflow trainable variables
    :param name2nparr: a dictionary in same format with output, if given, the converted tvars will be added to this
    :return: the dictionary in the format of {dict: np.Array}
    """
    if not name2nparr:
        name2nparr = {}

    name2nparr.update({var.name: var.numpy() for var in tvars})
    return name2nparr