docstr: Args:
      num_walkers:
      mcmc_steps:
      iters:
      thin:
      stats_interval:
      output_interval:
      initial_jitter:
      final_jitter:
      init_samples:
      moves:
  
  Returns:
code: def bootstrap(
      self,
      mcmc_steps,
      num_walkers,
      iters=1,
      thin=10,
      stats_interval=10,
      output_interval=None,
      initial_jitter=0.01,
      final_jitter=0.01,
      init_samples=None,
      moves=None,
  ):
      """
  
      Args:
          num_walkers:
          mcmc_steps:
          iters:
          thin:
          stats_interval:
          output_interval:
          initial_jitter:
          final_jitter:
          init_samples:
          moves:
  
      Returns:
  
      """
  
      def log_prob(x):
          logl, der = self.loglike(x)
          return logl + self.prior(x), der
  
      if (
          not os.path.isfile(os.path.join(self.log_dir, "emcee.h5"))
          and init_samples is None
      ):
          if self.sample_prior is not None:
              init_samples = self.sample_prior(num_walkers)
          else:
              raise ValueError("Prior does not have sample method")
      try:
          import emcee
      except:
          raise ImportError
  
      if moves is not None:
          ensemble_moves = []
          for k, v in moves.items():
              if k.lower() == "stretch":
                  ensemble_moves.append((emcee.moves.StretchMove(), v))
              elif k.lower() == "kde":
                  ensemble_moves.append((emcee.moves.KDEMove(), v))
              elif k.lower() == "de":
                  ensemble_moves.append((emcee.moves.DEMove(), v))
              elif k.lower() == "snooker":
                  ensemble_moves.append(
                      (emcee.moves.DESnookerMove(), v)
                  )
      else:
          ensemble_moves = [(emcee.moves.StretchMove(), 1.0)]
  
      self.logger.info(
          "Performing initial emcee run with [%d] walkers"
          % (num_walkers)
      )
      sampler = emcee.EnsembleSampler(
          num_walkers,
          self.x_dim,
          log_prob,
          moves=ensemble_moves,
          backend=emcee.backends.HDFBackend(
              os.path.join(self.log_dir, "emcee.h5")
          ),
      )
      state = sampler.run_mcmc(init_samples, mcmc_steps)
      self.logger.info(
          "Initial acceptance [%5.4f]"
          % (np.mean(sampler.acceptance_fraction))
      )
      self._chain_stats(
          np.transpose(sampler.get_chain(), axes=[1, 0, 2])
      )
  
      tau = sampler.get_autocorr_time()
      training_samples = sampler.get_chain(
          discard=int(2 * np.max(tau)),
          flat=True,
          thin=int(0.5 * np.min(tau)),
      )
  
      for it in range(1, iters + 1):
          if iters > 1:
              jitter = initial_jitter + (it - 1) * (
                  final_jitter - initial_jitter
              ) / (iters - 1)
          else:
              jitter = initial_jitter
  
          mean = np.mean(training_samples, axis=0)
          std = np.std(training_samples, axis=0)
          # Normalise samples
          training_samples = (training_samples - mean) / std
          self.transform = lambda x: x * std + mean
          self.trainer.train(training_samples, jitter=jitter)
  
          init_samples = None
          init_loglikes = None
          init_derived = None
  
          (
              samples,
              latent_samples,
              derived_samples,
              loglikes,
              ncall,
          ) = self._ensemble_sample(
              mcmc_steps,
              num_walkers,
              init_samples=init_samples,
              init_loglikes=init_loglikes,
              init_derived=init_derived,
              stats_interval=stats_interval,
              output_interval=output_interval,
          )
  
          # Remember last position and loglikes
          # init_samples = samples[:, -1, :]
          # init_loglikes = loglikes[:, -1]
          # init_derived = derived_samples[:, -1, :]
  
          samples = self.transform(samples)
          self._chain_stats(samples)
  
          mc = MCSamples(
              samples=[
                  samples[i, :, :].squeeze()
                  for i in range(samples.shape[0])
              ],
              loglikes=[
                  -loglikes[i, :].squeeze()
                  for i in range(loglikes.shape[0])
              ],
          )
          training_samples = mc.makeSingleSamples(single_thin=thin)
  
      return training_samples
  
file_path: nnest/nnest/ensemble.py
imports: from __future__ import print_function
  from __future__ import division
  import logging
  import os
  import numpy
  from getdist.mcsamples import MCSamples
  from nnest.sampler import Sampler
label_desc: Use image node_id 2 for calling the EnsembleSampler obj's underlying member method code with example usage: obj.bootstrap(mcmc_steps, num_walkers, iters, thin, stats_interval, output_interval, initial_jitter, final_jitter, init_samples, moves) and returns: training_samples, unknown,  der