
    sg                     b    d dl mZ g dZ G d de      Zd Z G d de      Z G d d	e
      Zy)   )typename)VariadicSignatureType
isvariadicVariadicSignatureMetaVariadicc                       e Zd Zd Zd Zd Zy)r   c                 l     t        |      r|j                  n|f}| u xs t         fd|D              S )Nc              3   J   K   | ]  }t        |j                          y wN)
issubclassvariadic_type).0otherclss     n/var/www/html/venv/lib/python3.12/site-packages/torch/fx/experimental/unification/multipledispatch/variadic.py	<genexpr>z:VariadicSignatureType.__subclasscheck__.<locals>.<genexpr>   s#      &
5:Juc//0&
s    #)r   r   all)r   subclass
other_types   `  r   __subclasscheck__z'VariadicSignatureType.__subclasscheck__   sB    0:80Dh,,$; 	3 
# &
>H&
 #
 	
    c                 r    t        |      xr+ t        | j                        t        |j                        k(  S )a  
        Return True if other has the same variadic type
        Parameters
        ----------
        other : object (type)
            The object (type) to check
        Returns
        -------
        bool
            Whether or not `other` is equal to `self`
        )r   setr   )r   r   s     r   __eq__zVariadicSignatureType.__eq__   s6     5! CC%%&#e.A.A*BB	Dr   c                 T    t        t        |       t        | j                        f      S r   )hashtype	frozensetr   )r   s    r   __hash__zVariadicSignatureType.__hash__   s!    T#Y	#*;*; <=>>r   N)__name__
__module____qualname__r   r   r    r   r   r   r      s    
D?r   r   c                 "    t        | t              S )a@  Check whether the type `obj` is variadic.
    Parameters
    ----------
    obj : type
        The type to check
    Returns
    -------
    bool
        Whether or not `obj` is variadic
    Examples
    --------
    >>> # xdoctest: +SKIP
    >>> isvariadic(int)
    False
    >>> isvariadic(Variadic[int])
    True
    )
isinstancer   )objs    r   r   r   "   s    $ c011r   c                       e Zd ZdZd Zy)r   zA metaclass that overrides ``__getitem__`` on the class. This is used to
    generate a new type for Variadic signatures. See the Variadic class for
    examples of how this behaves.
    c                     t        |t        t        f      st        |      st        d      t        |t              s|f}t	        dt        |       ddt        |d            S )NzVVariadic types must be type or tuple of types (Variadic[int] or Variadic[(int, float)]z	Variadic[]r#   )r   	__slots__)r%   r   tuple
ValueErrorr   r   dict)r   r   s     r   __getitem__z!VariadicSignatureMeta.__getitem__<   sk    =4-8D<O I J J -/)NM$/02};
 	
r   N)r    r!   r"   __doc__r.   r#   r   r   r   r   7   s    
r   r   c                       e Zd ZdZy)r   ar  A class whose getitem method can be used to generate a new type
    representing a specific variadic signature.
    Examples
    --------
    >>> # xdoctest: +SKIP
    >>> Variadic[int]  # any number of int arguments
    <class 'multipledispatch.variadic.Variadic[int]'>
    >>> Variadic[(int, str)]  # any number of one of int or str arguments
    <class 'multipledispatch.variadic.Variadic[(int, str)]'>
    >>> issubclass(int, Variadic[int])
    True
    >>> issubclass(int, Variadic[(int, str)])
    True
    >>> issubclass(str, Variadic[(int, str)])
    True
    >>> issubclass(float, Variadic[(int, str)])
    False
    N)r    r!   r"   r/   r#   r   r   r   r   J   s    r   r   )	metaclassN)utilsr   __all__r   r   r   r   r   r#   r   r   <module>r4      s7    
V?D ?82*
D 
&. r   