class_docstr: Class for Slice sampler.
  
  Parameters
  ----------
  model : Distribution from which sampling has done
  w     : Initial width for slice
  tune  : Flag for tuning
docstr: Helper function which implements slice sampler.
docstr_tok: ["Helper","function","which","implements","slice","sampler","."]
code: def _sample(self, q0):
      """
      Helper function which implements slice sampler.
      """
      self.w = np.resize(self.w, len(q0))  # this is a repmat
      q = np.copy(q0)
      ql = np.copy(q0)  # l for left boundary
      qr = np.copy(q0)  # r for right boudary
      for i, _ in enumerate(q0):
          # uniformly sample from 0 to p(q), but in log space
          y = self.model.logp(q) - nr.standard_exponential()
          ql[i] = q[i] - nr.uniform(0, self.w[i])
          qr[i] = q[i] + self.w[i]
  
          # Stepping out procedure
          cnt = 0
          while y < self.model.logp(ql):
              ql[i] -= self.w[i]
              cnt += 1
              if cnt > self.iter_limit:
                  raise RuntimeError(LOOP_ERR_MSG % self.iter_limit)
          cnt = 0
          while y < self.model.logp(qr):
              qr[i] += self.w[i]
              cnt += 1
              if cnt > self.iter_limit:
                  raise RuntimeError(LOOP_ERR_MSG % self.iter_limit)
  
          cnt = 0
          q[i] = (qr[i] - ql[i]) * nr.rand() + ql[i]
          while self.model.logp(q) < y:
              # Sample uniformly from slice
              if q[i] > q0[i]:
                  qr[i] = q[i]
              elif q[i] < q0[i]:
                  ql[i] = q[i]
              q[i] = (qr[i] - ql[i]) * nr.rand() + ql[i]
              cnt += 1
              if cnt > self.iter_limit:
                  raise RuntimeError(LOOP_ERR_MSG % self.iter_limit)
  
          if self.tune:
              self.w[i] = self.w[i] * (
                  self.n_tunes / (self.n_tunes + 1)
              ) + (qr[i] - ql[i]) / (
                  self.n_tunes + 1
              )  # same as before
              qr[i] = q[i]
              ql[i] = q[i]
  
      if self.tune:
          self.n_tunes += 1
  
      return q
  
file_path: dragonfly/dragonfly/sampling/slice.py
imports: from __future__ import division
  import numpy
  import numpy.random
label_desc: Use image node_id 2 for calling the Slice obj's underlying member method code with example usage: obj._sample(q0) and returns: q