def get_stack_frame(n=<NUM_LIT:0>, strict=True):
frame_cur = inspect.currentframe()<EOL>for ix in range(n + <NUM_LIT:1>):<EOL><INDENT>frame_next = frame_cur.f_back<EOL>if frame_next is None:  <EOL><INDENT>if strict:<EOL><INDENT>raise AssertionError('<STR_LIT>' % ix)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>frame_cur = frame_next<EOL><DEDENT>return frame_cur<EOL>
Gets the current stack frame or any of its ancestors dynamically

Args:
    n (int): n=0 means the frame you called this function in.
             n=1 is the parent frame.
    strict (bool): (default = True)

Returns:
    frame: frame_cur

Example:
    >>> frame_cur = get_stack_frame(n=0)
    >>> print('frame_cur = %r' % (frame_cur,))
    >>> assert frame_cur.f_globals['frame_cur'] is frame_cur