<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def context_scope(ctx):
 """ Context as Python context. .. code-block:: python import nnabla as nn import nnabla.functions as F x = nn.Variable([2, 3 ,4]) ctx = nnabla_ext.cuda.context('0') with context_scope(ctx):
 # Inside with scope, the specified context is used. with parameter_scope('w1'):
 l1 = F.relu(F.affine(x, 64)) with parameter_scope('w2'):
 l2 = F.relu(F.affine(x, 64)) """

    global current_ctx
    global context_level
    context_level += 1
    prev_context = current_ctx
    current_ctx = ctx
    try:
        yield
    finally:
        context_level -= 1
        current_ctx = prev_context