parameters: (
      hilbert, *args, clusters=None, graph=None, d_max=1, **kwargs
  )
return_statement: return MetropolisSampler(hilbert, rule, *args, **kwargs)
docstring: r"""
      This sampler acts locally only on two local degree of freedom :math:`s_i` and :math:`s_j`,
      and proposes a new state: :math:`s_1 \dots s^\prime_i \dots s^\prime_j \dots s_N`,
      where in general :math:`s^\prime_i \neq s_i` and :math:`s^\prime_j \neq s_j`.
      The sites :math:`i` and :math:`j` are also chosen to be within a maximum graph
      distance of :math:`d_{\mathrm{max}}`.
  
      The transition probability associated to this sampler can
      be decomposed into two steps:
  
      1. A pair of indices :math:`i,j = 1\dots N`, and such that
         :math:`\mathrm{dist}(i,j) \leq d_{\mathrm{max}}`,
         is chosen with uniform probability.
  
      2. The sites are exchanged, i.e. :math:`s^\prime_i = s_j` and :math:`s^\prime_j = s_i`.
  
      Notice that this sampling method generates random permutations of the quantum
      numbers, thus global quantities such as the sum of the local quantum numbers
      are conserved during the sampling.
      This scheme should be used then only when sampling in a
      region where :math:`\sum_i s_i = \mathrm{constant} ` is needed,
      otherwise the sampling would be strongly not ergodic.
  
      Args:
          hilbert: The Hilbert space to sample.
          d_max: The maximum graph distance allowed for exchanges.
          n_chains: The total number of independent Markov chains across all MPI ranks. Either specify this or `n_chains_per_rank`.
          n_chains_per_rank: Number of independent chains on every MPI rank (default = 16).
          n_sweeps: Number of sweeps for each step along the chain. Defaults to the number of sites in the Hilbert space.
                  This is equivalent to subsampling the Markov chain.
          reset_chains: If True, resets the chain state when `reset` is called on every new sampling (default = False).
          machine_pow: The power to which the machine should be exponentiated to generate the pdf (default = 2).
          dtype: The dtype of the states sampled (default = np.float64).
  
      Examples:
            Sampling from a RBM machine in a 1D lattice of spin 1/2, using
            nearest-neighbor exchanges.
  
            >>> import netket as nk
            >>>
            >>> g=nk.graph.Hypercube(length=10,n_dim=2,pbc=True)
            >>> hi=nk.hilbert.Spin(s=0.5, N=g.n_nodes)
            >>>
            >>> # Construct a MetropolisExchange Sampler
            >>> sa = nk.sampler.MetropolisExchange(hi, graph=g)
            >>> print(sa)
            MetropolisSampler(rule = ExchangeRule(# of clusters: 200), n_chains = 16, n_sweeps = 100, reset_chains = False, machine_power = 2, dtype = <class 'numpy.float64'>)
docstring_summary: r"""
      This sampler acts locally only on two local degree of freedom :math:`s_i` and :math:`s_j`,
      and proposes a new state: :math:`s_1 \dots s^\prime_i \dots s^\prime_j \dots s_N`,
      where in general :math:`s^\prime_i \neq s_i` and :math:`s^\prime_j \neq s_j`.
      The sites :math:`i` and :math:`j` are also chosen to be within a maximum graph
      distance of :math:`d_{\mathrm{max}}`.
docstring_tokens: r This sampler acts locally only on two local degree of freedom : math : s_i and : math : s_j and proposes a new state : : math : s_1 \ dots s^ \ prime_i \ dots s^ \ prime_j \ dots s_N where in general : math : s^ \ prime_i \ neq s_i and : math : s^ \ prime_j \ neq s_j . The sites : math : i and : math : j are also chosen to be within a maximum graph distance of : math : d_ { \ mathrm { max }} .
function: def MetropolisExchange(
      hilbert, *args, clusters=None, graph=None, d_max=1, **kwargs
  ) -> MetropolisSampler:
      r"""
      This sampler acts locally only on two local degree of freedom :math:`s_i` and :math:`s_j`,
      and proposes a new state: :math:`s_1 \dots s^\prime_i \dots s^\prime_j \dots s_N`,
      where in general :math:`s^\prime_i \neq s_i` and :math:`s^\prime_j \neq s_j`.
      The sites :math:`i` and :math:`j` are also chosen to be within a maximum graph
      distance of :math:`d_{\mathrm{max}}`.
  
      The transition probability associated to this sampler can
      be decomposed into two steps:
  
      1. A pair of indices :math:`i,j = 1\dots N`, and such that
         :math:`\mathrm{dist}(i,j) \leq d_{\mathrm{max}}`,
         is chosen with uniform probability.
  
      2. The sites are exchanged, i.e. :math:`s^\prime_i = s_j` and :math:`s^\prime_j = s_i`.
  
      Notice that this sampling method generates random permutations of the quantum
      numbers, thus global quantities such as the sum of the local quantum numbers
      are conserved during the sampling.
      This scheme should be used then only when sampling in a
      region where :math:`\sum_i s_i = \mathrm{constant} ` is needed,
      otherwise the sampling would be strongly not ergodic.
  
      Args:
          hilbert: The Hilbert space to sample.
          d_max: The maximum graph distance allowed for exchanges.
          n_chains: The total number of independent Markov chains across all MPI ranks. Either specify this or `n_chains_per_rank`.
          n_chains_per_rank: Number of independent chains on every MPI rank (default = 16).
          n_sweeps: Number of sweeps for each step along the chain. Defaults to the number of sites in the Hilbert space.
                  This is equivalent to subsampling the Markov chain.
          reset_chains: If True, resets the chain state when `reset` is called on every new sampling (default = False).
          machine_pow: The power to which the machine should be exponentiated to generate the pdf (default = 2).
          dtype: The dtype of the states sampled (default = np.float64).
  
      Examples:
            Sampling from a RBM machine in a 1D lattice of spin 1/2, using
            nearest-neighbor exchanges.
  
            >>> import netket as nk
            >>>
            >>> g=nk.graph.Hypercube(length=10,n_dim=2,pbc=True)
            >>> hi=nk.hilbert.Spin(s=0.5, N=g.n_nodes)
            >>>
            >>> # Construct a MetropolisExchange Sampler
            >>> sa = nk.sampler.MetropolisExchange(hi, graph=g)
            >>> print(sa)
            MetropolisSampler(rule = ExchangeRule(# of clusters: 200), n_chains = 16, n_sweeps = 100, reset_chains = False, machine_power = 2, dtype = <class 'numpy.float64'>)
      """
      from .rules import ExchangeRule
  
      rule = ExchangeRule(clusters=clusters, graph=graph, d_max=d_max)
      return MetropolisSampler(hilbert, rule, *args, **kwargs)
function_tokens: def MetropolisExchange ( hilbert , * args , clusters = None , graph = None , d_max = 1 , * * kwargs ) -> MetropolisSampler : from . rules import ExchangeRule rule = ExchangeRule ( clusters = clusters , graph = graph , d_max = d_max ) return MetropolisSampler ( hilbert , rule , * args , * * kwargs )