code: def make_events(add_nulls):
      """
      Every event has at least three pieces of data associated with it:
  
      1. sid : The ID of the asset associated with the event.
      2. event_date : The date on which an event occurred.
      3. timestamp : The date on which we learned about the event.
                     This can be before the occurence_date in the case of an
                     announcement about an upcoming event.
  
      Events for two different sids shouldn't interact in any way, so the
      interesting cases are determined by the possible interleavings of
      event_date and timestamp for a single sid.
  
      Fix two events with dates e1, e2 and timestamps t1 and t2.
  
      Without loss of generality, assume that e1 < e2. (If two events have the
      same occurrence date, the behavior of next/previous event is undefined).
  
      The remaining possible sequences of events are given by taking all possible
      4-tuples of four ascending dates. For each possible interleaving, we
      generate a set of fake events with those dates and assign them to a new
      sid.
      """
  
      def gen_date_interleavings():
          for e1, e2, t1, t2 in product(*[critical_dates] * 4):
              if e1 < e2:
                  yield (e1, e2, t1, t2)
  
      event_frames = []
      for sid, (e1, e2, t1, t2) in enumerate(gen_date_interleavings()):
          event_frames.append(
              make_events_for_sid(sid, [e1, e2], [t1, t2])
          )
  
      if add_nulls:
          for date in critical_dates:
              event_frames.append(
                  make_null_event_date_events(
                      np.arange(sid + 1),
                      timestamp=date,
                  )
              )
  
      return pd.concat(event_frames, ignore_index=True)
  
imports: from datetime import time
  import itertools
  from itertools import product
  import blaze
  from nose_parameterized import parameterized
  import numpy
  import pandas
  from catalyst.pipeline import Pipeline, SimplePipelineEngine
  from catalyst.pipeline.common import EVENT_DATE_FIELD_NAME, TS_FIELD_NAME, SID_FIELD_NAME
  from catalyst.pipeline.data import DataSet, Column
  from catalyst.pipeline.loaders.events import EventsLoader
  from catalyst.pipeline.loaders.blaze.events import BlazeEventsLoader
  from catalyst.pipeline.loaders.utils import next_event_indexer, normalize_timestamp_to_query_time, previous_event_indexer
  from catalyst.testing import check_arrays, CatalystTestCase
  from catalyst.testing.fixtures import WithAssetFinder, WithTradingSessions
  from catalyst.testing.predicates import assert_equal
  from catalyst.utils.numpy_utils import categorical_dtype, datetime64ns_dtype, float64_dtype, int64_dtype
label_desc: Use image node_id 3 for calling a global function with example usage: make_events(add_nulls) and returns: pd