A pretty useful reading material on scopes in Python: https://www.w3schools.com/python/python_scope.asp
Not counting global and nonlocal variables (you do not have any of these by the way), in inner2 the following variables are visible:
def outer1(i):
j = i + 1
def outer2():
k = j + 1
def inner1():
m = k + 1
def inner2():
n = m + 1
return n
m = inner2()
return m
k = inner1()
return k
j = outer2()
return j
print ("outer1(1) = ", outer1(1))That is, all the variables (i, j, k, m, n) is visible in inner2. See the "Function Inside Function" section in the above link.