code: def _compute_useful_frames(tb, num):
      """Return a list of frames, which form a 'useful' stack.
  
      Starting from the defining frame to the outermost one, this method computes
      the contiguous portion of the 'useful' stack trace and returns the selected
      frames.
  
      Args:
        tb: A list of traceback frames (as from Operation.traceback).
        num: total number of frames to return.
  
      Returns:
        A list of frames.
      """
      defining_frame_index = _find_index_of_defining_frame(tb)
      # The stack trace is collected from two lines before the defining frame in the
      # model file to the outermost with `num` frames at most. These two extra lines
      # are included from the TensorFlow library to give the context which node is
      # defined.
      innermost_excluded = min(defining_frame_index + 2 + 1, len(tb))
      outermost_included = max(innermost_excluded - num, 0)
      return tb[outermost_included:innermost_excluded]
  
file_path: tensorflow-upstream/tensorflow/python/framework/error_interpolation.py
imports: import collections
  import os
  import re
  import site
  import traceback
  from tensorflow.python.util import tf_stack
label_desc: Use image node_id 8 for calling a global function with example usage: _compute_useful_frames(tb, num) and returns: tb