def same_shape(shape1, shape2):
    """
    Checks if two shapes are the same
    Parameters
    ----------
    shape1 : tuple
        First shape
    shape2 : tuple
        Second shape
    Returns
    -------
    flag : bool
        True if both shapes are the same (same length and dimensions)
    """
    if len(shape1) != len(shape2):
        return False
    for i in range(len(shape1)):
        if shape1[i] != shape2[i]:
            return False
    return True