code: def main():
      """
      The task is to sleep 0.02 seconds for each data input and then multiply by 2.
      """
      sleep_time = 0.02
      preprocessing_and_model_steps = [
          ForEach(Sleep(sleep_time=sleep_time)),
          MultiplyByN(2),
      ]
  
      # Classical pipeline - all at once with one big batch:
      p = Pipeline(preprocessing_and_model_steps)
      time_vanilla_pipeline, output_classical = eval_run_time(p)
      print(
          f"Classical 'Pipeline' execution time: {time_vanilla_pipeline} seconds."
      )
  
      # Classical minibatch pipeline - minibatch size 5:
      p = MiniBatchSequentialPipeline(
          preprocessing_and_model_steps, batch_size=5
      )
      time_minibatch_pipeline, output_minibatch = eval_run_time(p)
      print(
          f"Minibatched 'MiniBatchSequentialPipeline' execution time: {time_minibatch_pipeline} seconds."
      )
  
      # Parallel pipeline - minibatch size 5 with 4 parallel workers per step that
      # have a max queue size of 10 batches between preprocessing and the model:
      p = SequentialQueuedPipeline(
          preprocessing_and_model_steps,
          n_workers_per_step=4,
          max_queued_minibatches=10,
          batch_size=5,
      )
      time_parallel_pipeline, output_parallel = eval_run_time(p)
      print(
          f"Parallel 'SequentialQueuedPipeline' execution time: {time_parallel_pipeline} seconds."
      )
  
      assert np.array_equal(output_classical, output_minibatch)
      assert np.array_equal(output_classical, output_parallel)
      assert time_parallel_pipeline < time_minibatch_pipeline, str(
          (time_parallel_pipeline, time_vanilla_pipeline)
      )
  
file_path: Neuraxle/examples/parallel/plot_streaming_pipeline.py
imports: import time
  import numpy
  from neuraxle.base import ExecutionContext
  from neuraxle.distributed.streaming import SequentialQueuedPipeline
  from neuraxle.pipeline import BasePipeline, Pipeline, MiniBatchSequentialPipeline
  from neuraxle.steps.loop import ForEach
  from neuraxle.steps.misc import Sleep
  from neuraxle.steps.numpy import MultiplyByN
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types