<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def demeshgrid(arr):
 """Turns an ndarray created by a meshgrid back into a 1D array Parameters arr : array of dimension > 1 This array should have been created by a meshgrid. """

    dim = len(arr.shape)
    for i in range(dim):
        Slice1 = [0]*dim
        Slice2 = [1]*dim
        Slice1[i] = slice(None)
        Slice2[i] = slice(None)
        if (arr[tuple(Slice1)] == arr[tuple(Slice2)]).all():
            return arr[tuple(Slice1)]