o
    pi%                     @   s(   d dl mZ ddlmZ dadd ZdS )    )signature_safe_contextmanager   )ProgramFc                  C   sP   t d	dd} d
dd}| |d}ts&| D ]
\}}tt|| qdad S d S )NFc                 s   s    d V  d S )N )selfZis_with_optr   r   _/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/paddle/pir/program_patch.py_lr_schedule_guard   s   
z0monkey_patch_program.<locals>._lr_schedule_guardallc                 S   sZ   ddl m} ddlm} |d ur t||js tdt| d|d u r'| }| ||S )Nr   )core)global_scopezD`scope` should be None or `paddle.static.Scope'` type, but received .)	Zpaddle.baser
   Zpaddle.base.executorr   
isinstanceZ_Scope	TypeErrortypeZ_state_dict)r   modescoper
   r   r   r   r   
state_dict   s   z(monkey_patch_program.<locals>.state_dict)r   r   T)F)r	   N)r   _already_patch_programitemssetattrr   )r   r   Zprogram_attrsattrvaluer   r   r   monkey_patch_program   s   
r   N)Zpaddle.base.wrapped_decoratorr    r   r   r   r   r   r   r   <module>   s   