code: def _strip_unnecessary_contents_from_stack(result, processed):
    
    # pylint: disable=protected-access
    if isinstance(result, (PrettyTensor, Loss)):
      if result.is_sequence():
        for tensor in result.sequence:
          _strip_unnecessary_contents_from_stack(tensor, processed)
          return
      else:
        result = result.tensor
    if hasattr(result, 'op'):
      result = result.op
    if result in processed:
      return
    else:
      processed.add(result)
    trace = []
    found = False
    for f, line_no, method, _ in result._traceback:
      if (method in ('_replace_deferred', '_construct') and
          f.endswith('pretty_tensor_class.py')):
        found = True
        continue
      trace.append((f, line_no, method, {}))
    result._traceback = trace
  
    # Assume that if we didn't find any PT deferred lines, then this node is
    # not part of the deferred construction.
    if not found:
      return
    for inp in result.inputs:
      _strip_unnecessary_contents_from_stack(inp, processed)
docs: Remove the distracting lines from the stored tracebacks.
  
    This also reduces memory overhead by removing the frame contents. This is very
    important when doing long unrolls.
  
    Args:
      result: The result to process.
      processed: A set of already processed nodes, used to stop early.