<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_dense(base_data, non_label_cols, **kwargs):
 """ Formats dense data type to stacked data type. Takes in a dense data type and converts into a stacked data type. Parameters data : DataFrame The dense data non_label_cols : list A list of columns in the data that are not label columns label_col : str Name of the label column in the formatted data. Default, "label" count_col : str Name of the count column in the formatted data. Default, "count" nan_to_zero : bool Set all nans to zero. Default, False drop_na : bool Drop all columns with nan in the dataset. Default, False Returns ------- : DataFrame A formatted DataFrame in the stacked format Notes ----- Example of Dense Data conversion 'labelA': [1,0,3,4], 'labelB' : [3,2,1,4]}) column labelA labelB row 0 1 1 3 1 1 1 0 2 2 2 2 3 1 1 3 2 4 4 2 [4 rows x 4 columns] # labelA and labelB might be species names. 'row' and 'column' # are non-species names so pass these in as non_label_cols row column label count 0 1 1 labelA 1 1 1 1 labelB 3 2 2 1 labelA 0 3 2 1 labelB 2 4 1 2 labelA 3 5 1 2 labelB 1 6 2 2 labelA 4 7 2 2 labelB 4 [8 rows x 4 columns] """


    kwargs = _set_dense_defaults_and_eval(kwargs)

    # Stack data in columnar form.
    indexed_data = base_data.set_index(keys=non_label_cols)
    columnar_data = indexed_data.stack(dropna=False)
    columnar_data = columnar_data.reset_index()

    # Rename columns
    num = len(non_label_cols)
    columnar_data.rename(columns={0: kwargs['count_col'], 'level_%i' % num:
        kwargs['label_col']}, inplace=True)

    # Set nans to zero?
    if kwargs['nan_to_zero']:
        ind = np.isnan(columnar_data[kwargs['count_col']])
        columnar_data.loc[ind, kwargs['count_col']] = 0
        columnar_data.reset_index(inplace=True, drop=True)

    # Drop nans?
    if kwargs['drop_na']:
        columnar_data = columnar_data.dropna(how="any")
        columnar_data.reset_index(inplace=True, drop=True)

    return columnar_data