<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_event_study_tear_sheet(factor_data, prices=None, avgretplot=(5, 15), rate_of_ret=True, n_bars=50):
 """ Creates an event study tear sheet for analysis of a specific event. Parameters factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single event, forward returns for each period, the factor quantile/bin that factor value belongs to, and (optionally) the group the asset belongs to. prices : pd.DataFrame, required only if 'avgretplot' is provided A DataFrame indexed by date with assets in the columns containing the pricing data. - See full explanation in utils.get_clean_factor_and_forward_returns avgretplot: tuple (int, int) - (before, after), optional If not None, plot event style average cumulative returns within a window (pre and post event). rate_of_ret : bool, optional Display rate of return instead of simple return in 'Mean Period Wise Return By Factor Quantile' and 'Period Wise Return By Factor Quantile' plots n_bars : int, optional Number of bars in event distribution plot """


    long_short = False

    plotting.plot_quantile_statistics_table(factor_data)

    gf = GridFigure(rows=1, cols=1)
    plotting.plot_events_distribution(events=factor_data['factor'],
                                      num_bars=n_bars,
                                      ax=gf.next_row())
    plt.show()
    gf.close()

    if prices is not None and avgretplot is not None:

        create_event_returns_tear_sheet(factor_data=factor_data,
                                        prices=prices,
                                        avgretplot=avgretplot,
                                        long_short=long_short,
                                        group_neutral=False,
                                        std_bar=True,
                                        by_group=False)

    factor_returns = perf.factor_returns(factor_data,
                                         demeaned=False,
                                         equal_weight=True)

    mean_quant_ret, std_quantile = \
        perf.mean_return_by_quantile(factor_data,
                                     by_group=False,
                                     demeaned=long_short)
    if rate_of_ret:
        mean_quant_ret = \
            mean_quant_ret.apply(utils.rate_of_return, axis=0,
                                 base_period=mean_quant_ret.columns[0])

    mean_quant_ret_bydate, std_quant_daily = \
        perf.mean_return_by_quantile(factor_data,
                                     by_date=True,
                                     by_group=False,
                                     demeaned=long_short)
    if rate_of_ret:
        mean_quant_ret_bydate = mean_quant_ret_bydate.apply(
            utils.rate_of_return, axis=0,
            base_period=mean_quant_ret_bydate.columns[0]
        )

    fr_cols = len(factor_returns.columns)
    vertical_sections = 2 + fr_cols * 1
    gf = GridFigure(rows=vertical_sections, cols=1)

    plotting.plot_quantile_returns_bar(mean_quant_ret,
                                       by_group=False,
                                       ylim_percentiles=None,
                                       ax=gf.next_row())

    plotting.plot_quantile_returns_violin(mean_quant_ret_bydate,
                                          ylim_percentiles=(1, 99),
                                          ax=gf.next_row())

    trading_calendar = factor_data.index.levels[0].freq
    if trading_calendar is None:
        trading_calendar = pd.tseries.offsets.BDay()
        warnings.warn(
            "'freq' not set in factor_data index: assuming business day",
            UserWarning
        )

    for p in factor_returns:

        plotting.plot_cumulative_returns(
            factor_returns[p],
            period=p,
            freq=trading_calendar,
            ax=gf.next_row()
        )

    plt.show()
    gf.close()