Ë
    øÿæiá  ã                   ó    — d dl Z  G d„ d«      Zy)é    Nc            	       ó  — e Zd ZdZdZdZdd„Z	 	 	 ddedej                  dz  dej                  dz  d	ej                  fd
„Z	 	 ddedej                  dz  dej                  dz  d	ej                  fd„Zd„ Zd„ Zd„ Zd„ Zy)ÚSobolEnginea  
    The :class:`torch.quasirandom.SobolEngine` is an engine for generating
    (scrambled) Sobol sequences. Sobol sequences are an example of low
    discrepancy quasi-random sequences.

    This implementation of an engine for Sobol sequences is capable of
    sampling sequences up to a maximum dimension of 21201. It uses direction
    numbers from https://web.maths.unsw.edu.au/~fkuo/sobol/ obtained using the
    search criterion D(6) up to the dimension 21201. This is the recommended
    choice by the authors.

    References:
      - Art B. Owen. Scrambling Sobol and Niederreiter-Xing points.
        Journal of Complexity, 14(4):466-489, December 1998.

      - I. M. Sobol. The distribution of points in a cube and the accurate
        evaluation of integrals.
        Zh. Vychisl. Mat. i Mat. Phys., 7:784-802, 1967.

    Args:
        dimension (Int): The dimensionality of the sequence to be drawn
        scramble (bool, optional): Setting this to ``True`` will produce
                                   scrambled Sobol sequences. Scrambling is
                                   capable of producing better Sobol
                                   sequences. Default: ``False``.
        seed (Int, optional): This is the seed for the scrambling. The seed
                              of the random number generator is set to this,
                              if specified. Otherwise, it uses a random seed.
                              Default: ``None``

    Examples::

        >>> # xdoctest: +SKIP("unseeded random state")
        >>> soboleng = torch.quasirandom.SobolEngine(dimension=5)
        >>> soboleng.draw(3)
        tensor([[0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
                [0.5000, 0.5000, 0.5000, 0.5000, 0.5000],
                [0.7500, 0.2500, 0.2500, 0.2500, 0.7500]])
    é   iÑR  Nc                 óä  — || j                   kD  s|dk  rt        d| j                   › d�«      ‚|| _        || _        || _        t        j                  d«      }t        j                  || j                  |t
        j                  ¬«      | _
        t        j                  | j                  | j                  «       | j                  s6t        j                  | j                  |t
        j                  ¬«      | _        n| j                  «        | j                  j                  t
        j                  ¬«      | _        | j                   d| j                  z  z  j#                  dd«      | _        d	| _        y )
Né   z9Supported range of dimensionality for SobolEngine is [1, Ú]Úcpu)ÚdeviceÚdtype)Úmemory_formaté   éÿÿÿÿr   )ÚMAXDIMÚ
ValueErrorÚseedÚscrambleÚ	dimensionÚtorchr
   ÚzerosÚMAXBITÚlongÚ
sobolstateÚ_sobol_engine_initialize_state_ÚshiftÚ	_scrambleÚcloneÚcontiguous_formatÚquasiÚreshapeÚ_first_pointÚnum_generated)Úselfr   r   r   r	   s        úf/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torch/quasirandom.pyÚ__init__zSobolEngine.__init__2   s  € Ø�t—{‘{Ò" i°!¢mÜð*Ø*.¯+©+¨°að9óð ð
 ˆŒ	Ø ˆŒØ"ˆŒä�l‰l˜5Ó!ˆäŸ+™+Ø�t—{‘{¨3´e·j±jô
ˆŒô 	×-Ñ-¨d¯o©o¸t¿~¹~ÔNà�}Š}ÜŸ™ T§^¡^¸CÄuÇzÁzÔRˆD�Jà�N‰NÔà—Z‘Z×%Ñ%´E×4KÑ4KÐ%ÓLˆŒ
Ø!ŸZ™Z¨!¨T¯[©[©.Ñ8×AÑAÀ!ÀRÓHˆÔØˆÕó    ÚnÚoutr   Úreturnc                 ó¢  — |€t        j                  «       }| j                  dk(  r¢|dk(  r| j                  j	                  |«      }nÏt        j
                  | j                  |dz
  | j                  | j                  | j                  |¬«      \  }| _        t        j                  | j                  j	                  |«      |fd¬«      }nNt        j
                  | j                  || j                  | j                  | j                  dz
  |¬«      \  }| _        | xj                  |z  c_        |�"|j                  |«      j                  |«       |S |S )ak  
        Function to draw a sequence of :attr:`n` points from a Sobol sequence.
        Note that the samples are dependent on the previous samples. The size
        of the result is :math:`(n, dimension)`.

        Args:
            n (Int, optional): The length of sequence of points to draw.
                               Default: 1
            out (Tensor, optional): The output tensor
            dtype (:class:`torch.dtype`, optional): the desired data type of the
                                                    returned tensor.
                                                    Default: ``None``
        r   r   )r   éþÿÿÿ)Údim)r   Úget_default_dtyper!   r    ÚtoÚ_sobol_engine_drawr   r   r   ÚcatÚ
resize_as_Úcopy_)r"   r&   r'   r   Úresults        r#   ÚdrawzSobolEngine.drawM   s"  € ð& ˆ=Ü×+Ñ+Ó-ˆEà×Ñ Ò"Ø�AŠvØ×*Ñ*×-Ñ-¨eÓ4‘ä%*×%=Ñ%=Ø—J‘JØ˜‘EØ—O‘OØ—N‘NØ×&Ñ&Øô&Ñ"�˜œ
ô Ÿ™ D×$5Ñ$5×$8Ñ$8¸Ó$?ÀÐ#HÈbÔQ‘ä!&×!9Ñ!9Ø—
‘
ØØ—‘Ø—‘Ø×"Ñ" QÑ&Øô"ÑˆF�D”Jð 	×Ò˜aÑÕàˆ?Ø�N‰N˜6Ó"×(Ñ(¨Ô0ØˆJàˆr%   Úmc                 óÀ   — d|z  }| j                   |z   }||dz
  z  dk(  s,t        d| j                   › d| j                   › d|› d|› d�	«      ‚| j                  |||¬	«      S )
aI  
        Function to draw a sequence of :attr:`2**m` points from a Sobol sequence.
        Note that the samples are dependent on the previous samples. The size
        of the result is :math:`(2**m, dimension)`.

        Args:
            m (Int): The (base2) exponent of the number of points to draw.
            out (Tensor, optional): The output tensor
            dtype (:class:`torch.dtype`, optional): the desired data type of the
                                                    returned tensor.
                                                    Default: ``None``
        r   r   r   zFThe balance properties of Sobol' points require n to be a power of 2. z0 points have been previously generated, then: n=z+2**Ú=zH. If you still want to do this, please use 'SobolEngine.draw()' instead.)r&   r'   r   )r!   r   r3   )r"   r4   r'   r   r&   Útotal_ns         r#   Ú
draw_base2zSobolEngine.draw_base2‚   s‹   € ð$ ˆq‰DˆØ×$Ñ$ qÑ(ˆØ˜7 Q™;Ñ'¨1Ò,Üð)Ø)-×);Ñ);Ð(<ð =1Ø15×1CÑ1CÐ0DÀDÈÈÈ1ÈWÈIð V0ð0óð ð �y‰y˜1 #¨UˆyÓ3Ð3r%   c                 ó^   — | j                   j                  | j                  «       d| _        | S )zF
        Function to reset the ``SobolEngine`` to base state.
        r   )r   r1   r   r!   )r"   s    r#   ÚresetzSobolEngine.reset    s'   € ð 	�
‰
×Ñ˜Ÿ™Ô$ØˆÔØˆr%   c                 ó`  — | j                   dk(  rEt        j                  | j                  |dz
  | j                  | j
                  | j                   «       nDt        j                  | j                  || j                  | j
                  | j                   dz
  «       | xj                   |z  c_         | S )a  
        Function to fast-forward the state of the ``SobolEngine`` by
        :attr:`n` steps. This is equivalent to drawing :attr:`n` samples
        without using the samples.

        Args:
            n (Int): The number of steps to fast-forward by.
        r   r   )r!   r   Ú_sobol_engine_ff_r   r   r   )r"   r&   s     r#   Úfast_forwardzSobolEngine.fast_forward¨   sŒ   € ð ×Ñ Ò"Ü×#Ñ#Ø—
‘
˜A ™E 4§?¡?°D·N±NÀD×DVÑDVõô ×#Ñ#Ø—
‘
˜A˜tŸ™°·±À×@RÑ@RÐUVÑ@Vôð 	×Ò˜aÑÕØˆr%   c                 óŽ  — d }| j                   �/t        j                  «       }|j                  | j                   «       t        j                  d«      }t        j
                  d| j                  | j                  f||¬«      }t        j                  |t        j                  dt        j                  d| j                  |¬«      «      «      | _        | j                  | j                  | j                  f}t        j
                  d|||¬«      j                  «       }t        j                  | j                  || j                  «       y )Nr	   r   )r
   Ú	generatorr   )r
   )r   r   Ú	GeneratorÚmanual_seedr
   Úrandintr   r   ÚmvÚpowÚaranger   ÚtrilÚ_sobol_engine_scramble_r   )r"   Úgr	   Ú
shift_intsÚltm_dimsÚltms         r#   r   zSobolEngine._scramble¼   så   € Ø$(ˆØ�9‰9Ð Ü—‘Ó!ˆAØ�M‰M˜$Ÿ)™)Ô$ä�l‰l˜5Ó!ˆô —]‘]Ø�—‘ §¡Ð,°SÀAô
ˆ
ô —X‘XØœŸ	™	 !¤U§\¡\°!°T·[±[ÈÔ%MÓNó
ˆŒ
ð
 —N‘N D§K¡K°·±Ð=ˆÜ�m‰m˜A˜x°¸qÔA×FÑFÓHˆä×%Ñ% d§o¡o°s¸D¿N¹NÕKr%   c                 óà   — d| j                   › �g}| j                  r|dgz  }| j                  �|d| j                  › �gz  }| j                  j                  dz   dj                  |«      z   dz   S )Nz
dimension=zscramble=Truezseed=Ú(z, Ú))r   r   r   Ú	__class__Ú__name__Újoin)r"   Ú
fmt_strings     r#   Ú__repr__zSobolEngine.__repr__Ò   st   € Ø" 4§>¡>Ð"2Ð3Ð4ˆ
Ø�=Š=Ø˜?Ð+Ñ+ˆJØ�9‰9Ð Ø˜U 4§9¡9 +Ð.Ð/Ñ/ˆJØ�~‰~×&Ñ&¨Ñ,¨t¯y©y¸Ó/DÑDÀsÑJÐJr%   )FN)r   NN)NN)rP   Ú
__module__Ú__qualname__Ú__doc__r   r   r$   Úintr   ÚTensorr   r3   r8   r:   r=   r   rS   © r%   r#   r   r      sÅ   „ ñ&ðP €FØ€Fóð: Ø#'Ø$(ñ	3àð3ð �\‰\˜DÑ ð3ð �{‰{˜TÑ!ð	3ð
 
�‰ó3ðp $(Ø$(ñ	4àð4ð �\‰\˜DÑ ð4ð �{‰{˜TÑ!ð	4ð
 
�‰ó4ò<òò(Ló,Kr%   r   )r   r   rY   r%   r#   Ú<module>rZ      s   ðó ÷RKò RKr%   