docs: def generate_sample(self, initial_pos, num_adapt, num_samples, stepsize=None):
          """
          Returns a generator type object whose each iteration yields a sample
  
          Parameters
          ----------
          initial_pos: A 1d array like object
              Vector representing values of parameter position, the starting
              state in markov chain.
  
          num_adapt: int
              The number of interations to run the adaptation of stepsize
  
          num_samples: int
              Number of samples to be generated
  
          stepsize: float , defaults to None
              The stepsize for proposing new values of position and momentum in simulate_dynamics
              If None, then will be choosen suitably
  
          Returns
          -------
          genrator: yielding a numpy.array type object for a sample
  
          Examples
          --------
          >>> from pgmpy.sampling import NoUTurnSamplerDA as NUTSda, GradLogPDFGaussian
          >>> from pgmpy.factors.continuous import GaussianDistribution as JGD
          >>> import numpy as np
          >>> mean = np.array([1, -100])
          >>> covariance = np.array([[-12, 45], [45, -10]])
          >>> model = JGD(['a', 'b'], mean, covariance)
          >>> sampler = NUTSda(model=model, grad_log_pdf=GradLogPDFGaussian, simulate_dynamics=LeapFrog)
          >>> samples = sampler.generate_sample(initial_pos=np.array([12, -4]), num_adapt=10,
          ...                                   num_samples=10, stepsize=0.1)
          >>> samples
          <generator object NoUTurnSamplerDA.generate_sample at 0x7f4fed46a4c0>
          >>> samples_array = np.array([sample for sample in samples])
          >>> samples_array
          array([[ 11.89963386,  -4.06572636],
                 [ 10.3453755 ,  -7.5700289 ],
                 [-26.56899659, -15.3920684 ],
                 [-29.97143077, -12.0801625 ],
                 [-29.97143077, -12.0801625 ],
                 [-33.07960829,  -8.90440347],
                 [-55.28263496, -17.31718524],
                 [-55.28263496, -17.31718524],
                 [-56.63440044, -16.03309364],
                 [-63.880094  , -19.19981944]])
          """
          initial_pos = _check_1d_array_object(initial_pos, 'initial_pos')
          _check_length_equal(initial_pos, self.model.variables, 'initial_pos', 'model.variables')
  
          if stepsize is None:
              stepsize = self._find_reasonable_stepsize(initial_pos)
  
          if num_adapt <= 1:  # return sample generated using Simple HMC algorithm
              for sample in NoUTurnSampler(self.model, self.grad_log_pdf,
                                           self.simulate_dynamics).generate_sample(initial_pos, num_samples, stepsize):
                  yield sample
              return
          mu = np.log(10.0 * stepsize)
  
          stepsize_bar = 1.0
          h_bar = 0.0
  
          position_m = initial_pos.copy()
          num_adapt += 1
  
          for i in range(1, num_samples + 1):
  
              position_m, alpha, n_alpha = self._sample(position_m, stepsize)
  
              if i <= num_adapt:
                  stepsize, stepsize_bar, h_bar = self._adapt_params(stepsize, stepsize_bar, h_bar, mu,
                                                                     i, alpha, n_alpha)
              else:
                  stepsize = stepsize_bar
  
              yield position_m