class_docstr: Base class for evaluating gradient log of probability density function/ distribution
  
  Classes inheriting this base class can be passed as an argument for
  finding gradient log of probability distribution in inference algorithms
  
  The class should initialize  self.grad_log and self.log_pdf
  
  Parameters
  ----------
  variable_assignments : A 1d array like object (numpy.ndarray or list)
      Vector representing values(assignments) of variables at which we want to find gradient and log
  
  model : An instance of pgmpy.models
  
  Examples
  --------
  >>> from pgmpy.factors import GaussianDistribution
  >>> from pgmpy.inference.continuous import BaseGradLogPDF
  >>> import numpy as np
  >>> class GradLogGaussian(BaseGradLogPDF):
  ...     def __init__(self, position, model):
  ...         BaseGradLogPDF.__init__(self, position, model)
  ...         self.grad_log, self.log_pdf = self._get_gradient_log_pdf()
  ...     def _get_gradient_log_pdf(self):
  ...         sub_vec = self.position - self.model.mean.flatten()
  ...         grad = - np.dot(self.model.precision_matrix, sub_vec)
  ...         log_pdf = 0.5 * float(np.dot(sub_vec, grad))
  ...         return grad, log_pdf
  >>> mean = np.array([1, 1])
  >>> covariance = np.array([[1, 0.2], [0.2, 7]])
  >>> model = GaussianDistribution(['x', 'y'], mean, covariance)
  >>> dist_param = np.array([0.1, 0.9])
  >>> grad_logp, logp = GradLogGaussian(dist_param, model).get_gradient_log_pdf()
  >>> logp
  -0.4054597701149426
  >>> grad_logp
  array([ 0.90229885, -0.01149425])
class_docstr_tok: ["Base","class","for","evaluating","gradient","log","of","probability","density","function\/","distribution","Classes","inheriting","this","base","class","can","be","passed","as","an","argument","for","finding","gradient","log","of","probability","distribution","in","inference","algorithms","The","class","should","initialize","self.grad_log","and","self.log_pdf","Parameters","--","--","--","--","--","variable_assignments",":","A","1d","array","like","object","(","numpy.ndarray","or","list",")","Vector","representing","values","(","assignments",")","of","variables","at","which","we","want","to","find","gradient","and","log","model",":","An","instance","of","pgmpy.models","Examples","--","--","--","--",">",">",">","from","pgmpy.factors","import","GaussianDistribution",">",">",">","from","pgmpy.inference.continuous","import","BaseGradLogPDF",">",">",">","import","numpy","as","np",">",">",">","class","GradLogGaussian","(","BaseGradLogPDF",")",":","...","def","__init__","(","self",",","position",",","model",")",":","...","BaseGradLogPDF.__init__","(","self",",","position",",","model",")","...","self.grad_log",",","self.log_pdf","=","self._get_gradient_log_pdf","(",")","...","def","_get_gradient_log_pdf","(","self",")",":","...","sub_vec","=","self.position","-","self.model.mean.flatten","(",")","...","grad","=","-","np.dot","(","self.model.precision_matrix",",","sub_vec",")","...","log_pdf","=","0.5","*","float","(","np.dot","(","sub_vec",",","grad",")",")","...","return","grad",",","log_pdf",">",">",">","mean","=","np.array","(","[","1",",","1","]",")",">",">",">","covariance","=","np.array","(","[","[","1",",","0.2","]",",","[","0.2",",","7","]","]",")",">",">",">","model","=","GaussianDistribution","(","[","'","x","'",",","'","y","'","]",",","mean",",","covariance",")",">",">",">","dist_param","=","np.array","(","[","0.1",",","0.9","]",")",">",">",">","grad_logp",",","logp","=","GradLogGaussian","(","dist_param",",","model",")",".get_gradient_log_pdf","(",")",">",">",">","logp","-0.4054597701149426",">",">",">","grad_logp","array","(","[","0.90229885",",","-0.01149425","]",")"]
docstr: Returns the gradient log and log of model at given position
  
  Returns
  -------
  Returns a tuple of following types
  
  numpy.array: Representing gradient log of model at given position
  
  float: Representing log of model at given position
  
  Example
  --------
  >>> # Using implementation of GradLogPDFGaussian
  >>> from pgmpy.sampling.base import GradLogPDFGaussian
  >>> from pgmpy.factors.continuous import GaussianDistribution
  >>> import numpy as np
  >>> mean = np.array([1, 1])
  >>> covariance = np.array([[1, -5], [-5, 2]])
  >>> model = GaussianDistribution(['x', 'y'], mean, covariance)
  >>> dist_param = np.array([0.6, 0.8])
  >>> grad_logp, logp = GradLogPDFGaussian(dist_param, model).get_gradient_log_pdf()
  >>> logp
  0.025217391304347823
  >>> grad_logp
  array([-0.07826087, -0.09565217])
docstr_tok: ["Returns","the","gradient","log","and","log","of","model","at","given","position","Returns","--","--","--","-","Returns","a","tuple","of","following","types","numpy.array",":","Representing","gradient","log","of","model","at","given","position","float",":","Representing","log","of","model","at","given","position","Example","--","--","--","--",">",">",">","#","Using","implementation","of","GradLogPDFGaussian",">",">",">","from","pgmpy.sampling.base","import","GradLogPDFGaussian",">",">",">","from","pgmpy.factors.continuous","import","GaussianDistribution",">",">",">","import","numpy","as","np",">",">",">","mean","=","np.array","(","[","1",",","1","]",")",">",">",">","covariance","=","np.array","(","[","[","1",",","-5","]",",","[","-5",",","2","]","]",")",">",">",">","model","=","GaussianDistribution","(","[","'","x","'",",","'","y","'","]",",","mean",",","covariance",")",">",">",">","dist_param","=","np.array","(","[","0.6",",","0.8","]",")",">",">",">","grad_logp",",","logp","=","GradLogPDFGaussian","(","dist_param",",","model",")",".get_gradient_log_pdf","(",")",">",">",">","logp","0.025217391304347823",">",">",">","grad_logp","array","(","[","-0.07826087",",","-0.09565217","]",")"]
code: def get_gradient_log_pdf(self):
      """
      Returns the gradient log and log of model at given position
  
      Returns
      -------
      Returns a tuple of following types
  
      numpy.array: Representing gradient log of model at given position
  
      float: Representing log of model at given position
  
      Example
      --------
      >>> # Using implementation of GradLogPDFGaussian
      >>> from pgmpy.sampling.base import GradLogPDFGaussian
      >>> from pgmpy.factors.continuous import GaussianDistribution
      >>> import numpy as np
      >>> mean = np.array([1, 1])
      >>> covariance = np.array([[1, -5], [-5, 2]])
      >>> model = GaussianDistribution(['x', 'y'], mean, covariance)
      >>> dist_param = np.array([0.6, 0.8])
      >>> grad_logp, logp = GradLogPDFGaussian(dist_param, model).get_gradient_log_pdf()
      >>> logp
      0.025217391304347823
      >>> grad_logp
      array([-0.07826087, -0.09565217])
      """
      return self.grad_log, self.log_pdf
  
imports: import itertools
  import math
  import os
  import networkx
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from pgmpy.inference import Inference
  from pgmpy.utils import _check_1d_array_object, _check_length_equal, compat_fns
label_desc: Use image node_id 2 for calling the BaseGradLogPDF obj's underlying member method code with example usage: obj.get_gradient_log_pdf() and returns: self,  self