o
    h                     @   st  U d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
mZmZ d dlmZmZ dd Zded	e	e d
edefddZdefddZdefddZdefddZdededefddZdedededefddZdededede	e def
ddZeeeeedd d!eed"d#d!eed$d%d&d'eed(d%d)d'eed*d+d&d'eed,d+d)d'd-	Zeeef ed.< dS )/    N)partial)CallableDictList)FAKE_FILENAME_PREFIXis_optional)	ParsedDefSourceContextc                 C   s   t jt| j|S N)ospathjoinr   __name__)clsmethod_name r   P/var/www/html/ai/venv/lib/python3.10/site-packages/torch/jit/_dataclass_impls.py_get_fake_filename   s   r   name
body_lines	signaturereturnc           	   
   C   s   d dd |D }d| | d| }zt|}W n ty4 } ztd| d| j d|d }~ww t| |}t|t||d	d	d
||d	dS )N
c                 s   s    | ]}d | V  qdS )  Nr   ).0br   r   r   	<genexpr>   s    zcompose_fn.<locals>.<genexpr>zdef z:
z3TorchScript failed to synthesize dataclass method 'z' for class 'zJ'. Please file a bug report at <https://github.com/pytorch/pytorch/issues>r   )sourcefilenamefile_linenoleading_whitespace_len)ctxr   r   r   )	r   astparseSyntaxErrorRuntimeErrorr   r   r   r	   )	r   r   r   r   bodydeclpy_astefake_filenamer   r   r   
compose_fn   s,   
r+   c                    s   t dd t| D rtdt| j}g  g }|j D ]"\}}|j	}t
|tjr< | ||j|jd q|| q|j|d} fddt| D }t| dre|d	d
  d  t| d|pldgt|dS )Nc                 s   s    | ]	}|j tjuV  qd S r
   )default_factorydataclassesMISSINGr   fieldr   r   r   r   /   s
    

z%synthesize__init__.<locals>.<genexpr>zIDefault factory initializers are not supported in TorchScript dataclasses)
annotation)
parametersc                    s0   g | ]}|j r|j vrd |j d|j qS )zself.z = )initr   r/   	init_varsr   r   
<listcomp>K   s    
z&synthesize__init__.<locals>.<listcomp>__post_init__zself.__post_init__(, )__init__passr   )anyr-   fieldsNotImplementedErrorinspectr   r:   r2   itemsr1   
isinstanceInitVarappendreplacetypehasattrr   r+   str)r   r   paramsr   paramannr&   r   r4   r   synthesize__init__,   s,   


rL   c              
   C   s:   t | dd| j dddd t| D  d gdd	S )
N__repr__zreturn '(r8   c                 S   s$   g | ]}|j r|j d |j qS )z=self.)reprr   r/   r   r   r   r6   `   s    z&synthesize__repr__.<locals>.<listcomp>z)'z(self) -> strr<   )r+   r   r   r-   r>   r   r   r   r   synthesize__repr__Y   s   rQ   c                 C   s   t | ddgddS )N__hash__zUraise NotImplementedError('__hash__ is not supported for dataclasses in TorchScript')z(self) -> intr<   )r+   rP   r   r   r   synthesize__hash__l   s   rS   conversec                 C   s   t | |ddd| dgdS )NTFif val1 z val2: return False)allow_eqraise_on_noneinnersynthesize_comparison)r   r   rT   r   r   r   synthesize_equalityz   s   r[   oprV   c              	   C   s&   t | ||dd| dd| dgdS )NTrU   z val2: return Truez
elif val2 z val1: return False)rW   rX   rY   )r   r   r\   rV   r   r   r   synthesize_inequality   s   

r]   rW   rX   c                 C   s   g }t | D ]6}|jsq|d|j d|j g |t|js%|ndgdd |D d|r9d| j dnd	 q|d
|  t	| ||d| j ddS )Nzval1 = self.zval2 = other.z)if val1 is not None and val2 is not None:c                 S   s   g | ]}d | qS )r   r   )r   liner   r   r   r6      s    z)synthesize_comparison.<locals>.<listcomp>z&elif (val1 is None) != (val2 is None):z"  raise TypeError('Cannot compare z with None')z  return Falsezreturn z(self, other: z	) -> boolr<   )
r-   r>   compareextendr   r   rF   r   rD   r+   )r   r   rV   rW   rX   r&   r0   r   r   r   rZ      s6   

rZ   __eq__z!=)r   rT   __ne__z==__lt__<F)r   r\   rV   __le__T__gt__>__ge__)	r:   rM   rR   ra   rb   rc   re   rf   rh   DATACLASS_MAGIC_METHODS)r"   r-   r@   r   	functoolsr   typingr   r   r   torch._jit_internalr   r   torch._sourcesr   r	   r   rH   r+   rL   rQ   rS   r[   boolr]   rZ   ri   __annotations__r   r   r   r   <module>   sH   
-

#