
    sg                     |    d dl mZmZ d dlmZ d Zd Zd Zd Z eee	      d        Z
d Z eeee	      d	        Zy
)   )unifyreify)dispatchc                     t         j                  | | t        ft               t        j                  | t        ft
               | S )a   Register standard unify and reify operations on class
    This uses the type and __dict__ or __slots__ attributes to define the
    nature of the term
    See Also:
    >>> # xdoctest: +SKIP
    >>> class A(object):
    ...     def __init__(self, a, b):
    ...         self.a = a
    ...         self.b = b
    >>> unifiable(A)
    <class 'unification.more.A'>
    >>> x = var('x')
    >>> a = A(1, 2)
    >>> b = A(1, x)
    >>> unify(a, b, {})
    {~x: 2}
    )_unifyadddictunify_object_reifyreify_object)clss    Y/var/www/html/venv/lib/python3.12/site-packages/torch/fx/experimental/unification/more.py	unifiabler      s0    $ JJS$.
JJT{L)J    c                 J    t        | d      rt        | |      S t        | |      S )a   Reify a Python object with a substitution
    >>> # xdoctest: +SKIP
    >>> class Foo(object):
    ...     def __init__(self, a, b):
    ...         self.a = a
    ...         self.b = b
    ...     def __str__(self):
    ...         return "Foo(%s, %s)"%(str(self.a), str(self.b))
    >>> x = var('x')
    >>> f = Foo(1, x)
    >>> print(f)
    Foo(1, ~x)
    >>> print(reify_object(f, {x: 2}))
    Foo(1, 2)
    	__slots__)hasattr_reify_object_slots_reify_object_dictoss     r   r   r   #   s(      q+"1a((!!Q''r   c                     t         j                  t        |             }t        | j                  |      }|| j                  k(  r| S |j                  j                  |       |S N)object__new__typer   __dict__update)r   r   objds       r   r   r   9   sK    
..a
!Cajj!AAJJLLJr   c                    | j                   D cg c]  }t        | |       }}t        ||      }||k(  r| S t        j	                  t        |             }t        | j                   |      D ]  \  }}t        |||        |S c c}w r   )r   getattrr   r   r   r   zipsetattr)r   r   attrattrs	new_attrsnewobjslots          r   r   r   B   s~    *+++6$WQ6E6eQI	Q(akk95 	(JD$FD$'	( 7s   Bc                 h    t        t        | j                  | j                  | j                  f|       S )z! Reify a Python ``slice`` object )slicer   startstopstepr   s     r   r   r   N   s)     %!&&!&&11566r   c           
      B   t        |       t        |      k7  ryt        | d      rQt        | j                  D cg c]  }t	        | |       c}|j                  D cg c]  }t	        ||       c}|      S t        | j
                  |j
                  |      S c c}w c c}w )a   Unify two Python objects
    Unifies their type and ``__dict__`` attributes
    >>> # xdoctest: +SKIP
    >>> class Foo(object):
    ...     def __init__(self, a, b):
    ...         self.a = a
    ...         self.b = b
    ...     def __str__(self):
    ...         return "Foo(%s, %s)"%(str(self.a), str(self.b))
    >>> x = var('x')
    >>> f = Foo(1, x)
    >>> g = Foo(1, 2)
    >>> unify_object(f, g, {})
    {~x: 2}
    Fr   )r   r   r   r   r#   r   )uvr   r*   s       r   r
   r
   Y   s      Aw$q'q+1;;?4ga&?34;;?4ga&? 	 QZZQ//	 @?s   BB
c                     t        | j                  | j                  | j                  f|j                  |j                  |j                  f|      S )z! Unify a Python ``slice`` object )r   r-   r.   r/   )r1   r2   r   s      r   r   r   s   s9     !''166166*QWWaffaff,EqIIr   N)corer   r   r   r   r   r   r   r,   r	   r   r
   r    r   r   <module>r6      s^     :(,	 
%7 704 
%J Jr   