o
    vi	                     @   sR   d dl Z d dlmZ d dlmZ 	 ddgZdedefdd	Zd
edefddZdS )    N)Any)Registryr   locatetreturnc              	   C   s   | j | j}}|d}tdt|D ](}d|d| }| d| }zt|| u r1|W   S W q ty;   Y qw | d| S )zl
    Inverse of ``locate()``.

    Args:
        t: any object with ``__module__`` and ``__qualname__``
    .   N)
__module____qualname__splitrangelenjoinr   ImportError)r   modulequalnameZmodule_partskprefix	candidate r   X/data/cameron/vidgen/cosmos-policy/cosmos_policy/_src/imaginaire/lazy_config/registry.py_convert_target_to_string   s   

r   namec              
   C   sZ   t | }|du r+zddlm} W n ty& } z	td|  d|d}~ww || }|S )z
    Locate and return an object ``x`` using an input string ``{x.__module__}.{x.__qualname__}``,
    such as "module.submodule.class_name".

    Raise Exception if it cannot be found.
    Nr   )_locatez!Cannot dynamically locate object !)pydocr   Zhydra.utilsr   r   )r   objr   er   r   r   r   6   s   
)	r   typingr   Zfvcore.common.registryr   __all__strr   r   r   r   r   r   <module>   s   