sequince.flows
==============

.. py:module:: sequince.flows

.. autoapi-nested-parse::

   Flow interfaces used by Sequince transforms and proposals.



Classes
-------

.. autoapisummary::

   sequince.flows.NormalizingFlow


Functions
---------

.. autoapisummary::

   sequince.flows.flow_asarray
   sequince.flows.flow_state_dict
   sequince.flows.load_flow_state_dict
   sequince.flows.clone_flow


Module Contents
---------------

.. py:class:: NormalizingFlow

   Bases: :py:obj:`Protocol`


   Minimal interface for normalizing flows used by Sequince.


   .. py:attribute:: xp
      :type:  Any


   .. py:method:: fit(particles, context = None, *, rng = None, **kwargs)


   .. py:method:: forward(particles, context = None)

      Map particles into a transformed space and return log-Jacobians.



   .. py:method:: inverse(particles, context = None)

      Undo the transform applied by :meth:`forward`.



   .. py:method:: log_prob(particles, context = None)

      Evaluate the flow log-density in the original particle space.



   .. py:method:: sample(num_samples = 1, context = None, *, rng = None)

      Draw samples from the flow distribution.



.. py:function:: flow_asarray(flow, array)

   Cast ``array`` to the backend array type expected by ``flow``.


.. py:function:: flow_state_dict(flow)

   Return persistent flow state when the adapter exposes it.


.. py:function:: load_flow_state_dict(flow, state)

   Restore persistent flow state when supported by the adapter.


.. py:function:: clone_flow(flow)

   Return a fresh copy of ``flow``.

   External flow adapters can expose ``_init_args`` to control how the clone is
   reconstructed; otherwise ``deepcopy`` is used as a fallback.


