code: def profile(curr_step, start_step, end_step, profile_name='profile.json',
              early_exit=True):
      
      if curr_step == start_step:
          mx.nd.waitall()
          mx.profiler.set_config(profile_memory=False, profile_symbolic=True,
                                 profile_imperative=True, filename=profile_name,
                                 aggregate_stats=True)
          mx.profiler.set_state('run')
      elif curr_step == end_step:
          mx.nd.waitall()
          mx.profiler.set_state('stop')
          logging.info(mx.profiler.dumps())
          mx.profiler.dump()
          if early_exit:
              exit()
docs: profile the program between [start_step, end_step).