def safe_squeeze(arr: np.ndarray, axis: Optional[int] = None) -> np.ndarray:
    """
    Squeezes an array, but only if the axis specified has dim 1.
    """
    if axis is None:
        return arr.squeeze()

    try:
        return arr.squeeze(axis=axis)
    except ValueError:
        return arr

    Squeezes an array, but only if the axis specified has dim 1.
    
dpkd/transformers/src/transformers/models/conditional_detr/image_processing_conditional_detr.py