def flatten_array(x):
    """
    Returns flattened array of x.

    Args:
        x (array, array of arrays)

    Returns:
        flattened_array (array)
    """
    try:
        flattened_array = [item for sub in x for item in sub]
    except TypeError:
        flattened_array = x
    return flattened_array