code: def plot_events_distribution(events, num_bars=50, ax=None):
      """
      Plots the distribution of events in time.
  
      Parameters
      ----------
      events : pd.Series
          A pd.Series whose index contains at least 'date' level.
      num_bars : integer, optional
          Number of bars to plot
      ax : matplotlib.Axes, optional
          Axes upon which to plot.
  
      Returns
      -------
      ax : matplotlib.Axes
      """
  
      if ax is None:
          f, ax = plt.subplots(1, 1, figsize=(18, 6))
  
      start = events.index.get_level_values("date").min()
      end = events.index.get_level_values("date").max()
      group_interval = (end - start) / num_bars
      grouper = pd.Grouper(level="date", freq=group_interval)
      events.groupby(grouper).count().plot(
          kind="bar", grid=False, ax=ax
      )
      ax.set(
          ylabel="Number of events",
          title="Distribution of events in time",
          xlabel="Date",
      )
  
      return ax
  
imports: import numpy
  import pandas
  from scipy import stats
  import statsmodels.api
  import seaborn
  import matplotlib.cm
  import matplotlib.pyplot
  from matplotlib.ticker import ScalarFormatter
  from functools import wraps
  from .None import utils
  from .None import performance
label_desc: Use image node_id 21 for calling a global function with example usage: plot_events_distribution(events, num_bars, ax) and returns: ax