code: def stop(save=True):
      """Stops the current profiling session.
  
      The profiler session will be stopped and profile results can be saved.
  
      Args:
        save: An optional variable to save the results to TensorBoard. Default True.
  
      Raises:
        UnavailableError: If there is no active profiling session.
      """
      global _profiler
      with _profiler_lock:
          if _profiler is None:
              raise errors.UnavailableError(
                  None,
                  None,
                  "Cannot export profiling results. No profiler is running.",
              )
          if save:
              try:
                  _profiler.export_to_tb()
              except Exception:
                  _profiler = None
                  raise
          _profiler = None
  
file_path: tensorflow-upstream/tensorflow/python/profiler/profiler_v2.py
imports: import collections
  import threading
  from tensorflow.python.framework import errors
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.profiler.internal import _pywrap_profiler
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 2 for calling a global function with example usage: stop(save) without return types