def METHOD_NAME():
    sdfg = dace.SDFG('test_write_before_nested_map_exit')
    sdfg.add_array('A', (10, 10), dace.int32)
    sdfg.add_array('B', (10, 10), dace.int32)
    state = sdfg.add_state('state')
    me0, mx0 = state.add_map('map', dict(i='0:10'))
    me1, mx1 = state.add_map('map2', dict(j='0:10'))
    a_access = state.add_read('A')
    b_access = state.add_write('B')
    tasklet = state.add_tasklet('tasklet', {'__inp'}, {'__out'}, '__out = __inp')
    state.add_memlet_path(a_access, me0, me1, tasklet, memlet=dace.Memlet(data='A', subset='i, j'), dst_conn='__inp')
    state.add_edge(tasklet, '__out', b_access, None, dace.Memlet(data='B', subset='i, j'))
    state.add_nedge(b_access, mx1, dace.Memlet())
    state.add_nedge(mx1, mx0, dace.Memlet())
    A = np.arange(100, dtype=np.int32).reshape((10, 10)).copy()
    ref = A
    before_val = np.empty((10, 10), dtype=np.int32)
    after_val = np.empty((10, 10), dtype=np.int32)
    sdfg_before = copy.deepcopy(sdfg)
    sdfg_before(A=A, B=before_val)
    assert np.allclose(before_val, ref)
    sdfg.apply_transformations_repeated(RemoveIntermediateWrite)
    sdfg(A=A, B=after_val)
    assert np.allclose(after_val, ref)