a
    d                     @   s\  U d dl Z d dlmZ d dlmZmZ d dlmZmZ d dl	m
Z
mZmZ d dlZd dlZd dlZdd Zeee eedd	d
ZedddZedddZedddZeeedddZeeeedddZeeeee ed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)is_optionalFAKE_FILENAME_PREFIX)	ParsedDefSourceContext)CallableDictListc                 C   s   t jt| j|S N)ospathjoinr   __name__)clsmethod_name r   c/var/www/html/stable-diffusion-webui/venv/lib/python3.9/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yt } z&td| d| j d|W Y d }~n
d }~0 0 t| |}t|t||d	d	d
||d	dS )N
c                 s   s   | ]}d | V  qdS )  Nr   ).0br   r   r   	<genexpr>       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_linenoZleading_whitespace_len)ctxr   r   r    )	r   astparseSyntaxErrorRuntimeErrorr   r   r   r   )	r   r   r   r   bodydeclZpy_asteZfake_filenamer   r   r   
compose_fn   s.    
r)   )r   c                    s   t dd t| D r tdt| j}g  g }|j D ]D\}}|j	}t
|tjrx | ||j|jd q>|| q>|j|d} fddt| D }t| dr|d	d
  d  t| d|pd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   0   r   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-   Z	init_varsr   r   
<listcomp>G   s   z&synthesize__init__.<locals>.<listcomp>Z__post_init__zself.__post_init__(, )__init__passr   )anyr+   fieldsNotImplementedErrorinspectr   r6   r0   itemsr/   
isinstanceZInitVarappendreplacetypehasattrr   r)   str)r   r   paramsr   paramannr&   r   r2   r   synthesize__init__-   s$    


rG   c              
   C   s:   t | dd| j dddd t| D  d gdd	S )
N__repr__zreturn '(r4   c                 S   s$   g | ]}|j r|j d |j qS )z=self.)reprr   r-   r   r   r   r3   W   s   z&synthesize__repr__.<locals>.<listcomp>z)'z(self) -> strr8   )r)   r   r   r+   r:   r   r   r   r   synthesize__repr__T   s    rL   c                 C   s   t | ddgddS )N__hash__zUraise NotImplementedError('__hash__ is not supported for dataclasses in TorchScript')z(self) -> intr8   )r)   rK   r   r   r   synthesize__hash__^   s    rN   )r   converser   c                 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   rO   r   r   r   synthesize_equalityj   s    

rV   )r   oprQ   r   c              	   C   s&   t | ||dd| dd| dgdS )NTrP   z val2: return Truez
elif val2 z val1: return False)rR   rS   rT   )r   r   rW   rQ   r   r   r   synthesize_inequalityo   s    


rX   )r   rQ   rR   rS   r   c                 C   s   g }t | D ]l}|jsq|d|j d|j g |t|jsJ|n,dgdd |D d|rrd| 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   r3      r   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	) -> boolr8   )
r+   r:   compareextendr   r   rA   r   r?   r)   )r   r   rQ   rR   rS   r&   r.   r   r   r   rU   u   s*    


rU   __eq__z!=)r   rO   __ne__z==__lt__<F)r   rW   rQ   __le__T__gt__>__ge__)	r6   rH   rM   r\   r]   r^   r`   ra   rc   DATACLASS_MAGIC_METHODS)r   	functoolsr   Ztorch._jit_internalr   r   Ztorch._sourcesr   r   typingr   r   r	   r"   r+   r<   r   rC   r)   rG   rL   rN   rV   boolrX   rU   rd   __annotations__r   r   r   r   <module>   s2   
'
