def METHOD_NAME (matrix) :
    # Declaring an empty matrix to store the values after spiral conversion
    answer = []
    # Edge case condition if the matrix is empty we will return an empty array
    if(len(matrix) == 0) :
        return answer
    # Calculating the length of the row and column in the matrix
    row_len = len(matrix)
    col_len = len(matrix[0])
    """
    A boolean array which is used to check wheather the element is visited or not currently it is 0 for all elements in the matrix
    when it is visited it will be modified as 1 
    """
    visited = [[0 for i in range(col_len)] for j in range(row_len)]
    # Variables for iterating the rows and columns
    x = 0
    y = 0
    # The direction at which the matrix is being traversing that is either top or bottom or right or left.
    curr_direction = 0
    # Declaring how to change the row and columns to print the matrix in spiral order.
    spiral_row = [0,1,0,-1]
    spiral_col = [1,0,-1,0]
    # The loop which performs the spiral traversal of matrix
    for i in range(row_len * col_len) :
        # Adding the element to the answer array since it is not present in it.
        answer.append(matrix[x][y])
        # Modifiying the visited array because the element is added to the answer, since it is visited so converting it to 1
        visited[x][y] = True
        # Changing the index of the row and columns to traverse the next element.
        # It is used to change the rows and columns
        #  It is for the next rows and next columns to be added
        nr = x + spiral_row[curr_direction]
        nc = y + spiral_col[curr_direction]
        # If the current element is not visited and less than size then we should add it to the answer array this condtion performs it.
        if (0 <= nr and nr < row_len and 0 <= nc and nc < col_len and not(visited[nr][nc])):
            x = nr
            y = nc
        # Changing the direction of the rows and columns is done with the help of this condition.
        else:
            curr_direction = (curr_direction + 1) % 4
            x += spiral_row[curr_direction]
            y += spiral_col[curr_direction]
    # Return the array which is converted into spiral order.
    return answer