docs: def generate_sample(self, initial_pos, num_adapt, num_samples, trajectory_length, stepsize=None):
          """
          Method returns a generator type object whose each iteration yields a sample
          using Hamiltonian Monte Carlo
  
          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
  
          trajectory_length: int or float
              Target trajectory length, stepsize * number of steps(L),
              where L is the number of steps taken to propose new values of position and momentum
              per HMC iteration and stepsize is step size.
  
          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 HamiltonianMCDA as HMCda, GradLogPDFGaussian as GLPG, LeapFrog
          >>> from pgmpy.factors.continuous import GaussianDistribution as JGD
          >>> import numpy as np
          >>> mean = np.array([1, 1])
          >>> covariance = np.array([[1, 0.7], [0.7, 3]])
          >>> model = JGD(['x', 'y'], mean, covariance)
          >>> sampler = HMCda(model=model, grad_log_pdf=GLPG, simulate_dynamics=LeapFrog)
          >>> gen_samples = sampler.generate_sample(np.array([1, 1]), num_adapt=10000,
          ...                                       num_samples = 10000, trajectory_length=2, stepsize=None)
          >>> samples_array = np.array([sample for sample in gen_samples])
          >>> np.cov(samples_array.T)
          array([[ 0.98432155,  0.69517394],
                 [ 0.69517394,  2.95449533]])
          """
          self.accepted_proposals = 0
          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 HamiltonianMC.generate_sample(self, initial_pos, num_samples, trajectory_length, 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 = self._sample(position_m, trajectory_length, stepsize)
  
              if i <= num_adapt:
                  stepsize, stepsize_bar, h_bar = self._adapt_params(stepsize, stepsize_bar, h_bar, mu, i, alpha)
              else:
                  stepsize = stepsize_bar
  
              yield position_m
  
          self.acceptance_rate = self.accepted_proposals / num_samples