+
    &jB(                        R t ^ RIHtHt ^ RIHt . ROt ! R R4      t]! 4       t]! 4       t	]P                  ]P                  4      ]	P                  ]P                  4      R 4       4       t]P                  ]P                  4      R 4       t]	P                  ]P                  4      R 4       t]P                  ]P                   4      ]P                  ]P"                  4      ]	P                  ]P                   4      ]	P                  ]P"                  4      R 4       4       4       4       t]P                  ]P&                  4      ]P                  ]P(                  4      ]	P                  ]P&                  4      ]	P                  ]P(                  4      R	 4       4       4       4       t]P                  ]P,                  4      ]	P                  ]P,                  4      R
 4       4       t]P                  ]P0                  4      ]P                  ]P2                  4      ]	P                  ]P0                  4      ]	P                  ]P2                  4      R 4       4       4       4       t]P                  ]P6                  4      R 4       t]	P                  ]P6                  4      R 4       t]	P                  ]P<                  4      R 4       t]	P                  ]P@                  4      ]	P                  ]PB                  4      R 4       4       t"]P                  ]PF                  4      ]	P                  ]PF                  4      R 4       4       t$]P                  ]PJ                  4      R 4       t&]	P                  ]PJ                  4      R 4       t']P                  ]PP                  4      R 4       t)]	P                  ]PP                  4      R 4       t*R# )aF  
PyTorch provides two global :class:`ConstraintRegistry` objects that link
:class:`~torch.distributions.constraints.Constraint` objects to
:class:`~torch.distributions.transforms.Transform` objects. These objects both
input constraints and return transforms, but they have different guarantees on
bijectivity.

1. ``biject_to(constraint)`` looks up a bijective
   :class:`~torch.distributions.transforms.Transform` from ``constraints.real``
   to the given ``constraint``. The returned transform is guaranteed to have
   ``.bijective = True`` and should implement ``.log_abs_det_jacobian()``.
2. ``transform_to(constraint)`` looks up a not-necessarily bijective
   :class:`~torch.distributions.transforms.Transform` from ``constraints.real``
   to the given ``constraint``. The returned transform is not guaranteed to
   implement ``.log_abs_det_jacobian()``.

The ``transform_to()`` registry is useful for performing unconstrained
optimization on constrained parameters of probability distributions, which are
indicated by each distribution's ``.arg_constraints`` dict. These transforms often
overparameterize a space in order to avoid rotation; they are thus more
suitable for coordinate-wise optimization algorithms like Adam::

    loc = torch.zeros(100, requires_grad=True)
    unconstrained = torch.zeros(100, requires_grad=True)
    scale = transform_to(Normal.arg_constraints["scale"])(unconstrained)
    loss = -Normal(loc, scale).log_prob(data).sum()

The ``biject_to()`` registry is useful for Hamiltonian Monte Carlo, where
samples from a probability distribution with constrained ``.support`` are
propagated in an unconstrained space, and algorithms are typically rotation
invariant.::

    dist = Exponential(rate)
    unconstrained = torch.zeros(100, requires_grad=True)
    sample = biject_to(dist.support)(unconstrained)
    potential_energy = -dist.log_prob(sample).sum()

.. note::

    An example where ``transform_to`` and ``biject_to`` differ is
    ``constraints.simplex``: ``transform_to(constraints.simplex)`` returns a
    :class:`~torch.distributions.transforms.SoftmaxTransform` that simply
    exponentiates and normalizes its inputs; this is a cheap and mostly
    coordinate-wise operation appropriate for algorithms like SVI. In
    contrast, ``biject_to(constraints.simplex)`` returns a
    :class:`~torch.distributions.transforms.StickBreakingTransform` that
    bijects its input down to a one-fewer-dimensional space; this a more
    expensive less numerically stable transform but is needed for algorithms
    like HMC.

The ``biject_to`` and ``transform_to`` objects can be extended by user-defined
constraints and transforms using their ``.register()`` method either as a
function on singleton constraints::

    transform_to.register(my_constraint, my_transform)

or as a decorator on parameterized constraints::

    @transform_to.register(MyConstraintClass)
    def my_factory(constraint):
        assert isinstance(constraint, MyConstraintClass)
        return MyTransform(constraint.param1, constraint.param2)

You can create your own registry by creating a new :class:`ConstraintRegistry`
object.
)constraints
transforms)_NumberConstraintRegistryc                   F   a a ] tR t^Pt oRtV 3R ltRR ltR tRtVt	V ;t
# )r   z-
Registry to link constraints to transforms.
c                2   < / V n         \        SV `	  4        R # N)	_registrysuper__init__)self	__class__s   &/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/distributions/constraint_registry.pyr   ConstraintRegistry.__init__U   s        c                  a a Vf   VV 3R l# \        S\        P                  4      '       d   \        S4      o\        S\        4      '       d!   \	        S\        P                  4      '       g   \        RS 24      hVS P                  S&   V# )a  
Registers a :class:`~torch.distributions.constraints.Constraint`
subclass in this registry. Usage::

    @my_registry.register(MyConstraintClass)
    def construct_transform(constraint):
        assert isinstance(constraint, MyConstraint)
        return MyTransform(constraint.arg_constraints)

Args:
    constraint (subclass of :class:`~torch.distributions.constraints.Constraint`):
        A subclass of :class:`~torch.distributions.constraints.Constraint`, or
        a singleton object of the desired class.
    factory (Callable): A callable that inputs a constraint object and returns
        a  :class:`~torch.distributions.transforms.Transform` object.
c                 (   < SP                  SV 4      # r   )register)factory
constraintr   s   &r   <lambda>-ConstraintRegistry.register.<locals>.<lambda>l   s    4==W#Er   zLExpected constraint to be either a Constraint subclass or instance, but got )
isinstancer   
Constrainttype
issubclass	TypeErrorr	   r   r   r   s   ff&r   r   ConstraintRegistry.registerY   s    $ ?EE j+"8"899j)J*d++:..4
 4
 ^_i^jk  &-z"r   c                     V P                   \        V4      ,          pT! T4      #   \         d%    \        R\        T4      P                   R24      Rhi ; i)a   
Looks up a transform to constrained space, given a constraint object.
Usage::

    constraint = Normal.arg_constraints["scale"]
    scale = transform_to(constraint)(torch.zeros(1))  # constrained
    u = transform_to(constraint).inv(scale)  # unconstrained

Args:
    constraint (:class:`~torch.distributions.constraints.Constraint`):
        A constraint object.

Returns:
    A :class:`~torch.distributions.transforms.Transform` object.

Raises:
    `NotImplementedError` if no transform has been registered.
zCannot transform z constraintsN)r	   r   KeyErrorNotImplementedError__name__r   s   && r   __call__ConstraintRegistry.__call__|   s`    (	nnT*%56G
 z""	  	%#D$4$=$=#>lK	s	   & /A)r	   r   )r"   
__module____qualname____firstlineno____doc__r   r   r#   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r   r   P   s     !F# #r   c                 "    \         P                  # r   )r   identity_transformr   s   &r   _transform_to_realr0      s     (((r   c                 l    \        V P                  4      p\        P                  ! WP                  4      # r   )	biject_tobase_constraintr   IndependentTransformreinterpreted_batch_ndimsr   base_transforms   & r   _biject_to_independentr8      s.    z99:N**<< r   c                 l    \        V P                  4      p\        P                  ! WP                  4      # r   )transform_tor3   r   r4   r5   r6   s   & r   _transform_to_independentr;      s.    !*"<"<=N**<< r   c                 ,    \         P                  ! 4       # r   )r   ExpTransformr/   s   &r   _transform_to_positiver>      s    
 ""$$r   c                     \         P                  ! \         P                  ! 4       \         P                  ! V P                  ^4      .4      # )   )r   ComposeTransformr=   AffineTransformlower_boundr/   s   &r   _transform_to_greater_thanrD      s>    
 &&##%&&z'='=qA	
 r   c                     \         P                  ! \         P                  ! 4       \         P                  ! V P                  R4      .4      # )r@   )r   rA   r=   rB   upper_boundr/   s   &r   _transform_to_less_thanrH      s>     &&##%&&z'='=rB	
 r   c                    \        V P                  \        4      ;'       d    V P                  ^ 8H  p\        V P                  \        4      ;'       d    V P                  ^8H  pV'       d   V'       d   \        P
                  ! 4       # V P                  pV P                  V P                  ,
          p\        P                  ! \        P
                  ! 4       \        P                  ! W44      .4      # )    )r   rC   r   rG   r   SigmoidTransformrA   rB   )r   
lower_is_0
upper_is_1locscales   &    r   _transform_to_intervalrP      s     	:))73SS
8N8NRS8S  	:))73SS
8N8NRS8S  j**,,

 
 C""Z%;%;;E&&		$	$	&
(B(B3(NO r   c                 ,    \         P                  ! 4       # r   )r   StickBreakingTransformr/   s   &r   _biject_to_simplexrS          ,,..r   c                 ,    \         P                  ! 4       # r   )r   SoftmaxTransformr/   s   &r   _transform_to_simplexrW      s    &&((r   c                 ,    \         P                  ! 4       # r   )r   LowerCholeskyTransformr/   s   &r   _transform_to_lower_choleskyrZ      rT   r   c                 ,    \         P                  ! 4       # r   )r   PositiveDefiniteTransformr/   s   &r   _transform_to_positive_definiter]      s     //11r   c                 ,    \         P                  ! 4       # r   )r   CorrCholeskyTransformr/   s   &r   _transform_to_corr_choleskyr`     s     ++--r   c                     \         P                  ! V P                   Uu. uF  p\        V4      NK  	  upV P                  V P
                  4      # u upi r   )r   CatTransformcseqr2   dimlengthsr   cs   & r   _biject_to_catrh   
  s@    "")/!1/ASAS /   Ac                     \         P                  ! V P                   Uu. uF  p\        V4      NK  	  upV P                  V P
                  4      # u upi r   )r   rb   rc   r:   rd   re   rf   s   & r   _transform_to_catrk     s@    """,//2/Qa/2JNNJDVDV 2ri   c                     \         P                  ! V P                   Uu. uF  p\        V4      NK  	  upV P                  4      # u upi r   )r   StackTransformrc   r2   rd   rf   s   & r   _biject_to_stackrn     s8    $$)/!1/ /   Ac                     \         P                  ! V P                   Uu. uF  p\        V4      NK  	  upV P                  4      # u upi r   )r   rm   rc   r:   rd   rf   s   & r   _transform_to_stackrq     s8    $$",//2/Qa/2JNN 2ro   N)r   r2   r:   )+r(   torch.distributionsr   r   torch.typesr   __all__r   r2   r:   r   realr0   independentr8   r;   positivenonnegativer>   greater_thangreater_than_eqrD   	less_thanrH   intervalhalf_open_intervalrP   simplexrS   rW   lower_choleskyrZ   positive_definitepositive_semidefiniter]   corr_choleskyr`   catrh   rk   stackrn   rq    r   r   <module>r      s  AF 8 F# F#R  	!# K$$%{''() ) &) K++, - {../ 0 K(()
K++,{++,{../% 0 - - *% K,,-
K//0{//0{223 4 1 1 . K))*{,,- . + K(()
K223{++,{556 7 - 4 *$ K''(/ )/ {**+) ,)
 {112/ 3/ {445{8892 : 62 K--.{001. 2 /. KOO$ % {' ( K%%& ' {(() *r   