code: def closest_parent_sourcepos(elem):
      """
      Find the nearest defined sourcepos from a ancestor of elem.
      """
      while elem.sourcepos is None:
          elem = elem.parent
  
      return elem.sourcepos
  
imports: import argparse
  import commonmark
  import nbformat
  import os
  import re
  import subprocess
  import sys
  import textwrap
  from pathlib import Path
label_desc: Use image node_id 15 for calling a global function with example usage: closest_parent_sourcepos(elem) and returns: elem