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","]",")"]
code: def __init__(self, variable_assignments, model):
      self.variable_assignments = _check_1d_array_object(
          variable_assignments, "variable_assignments"
      )
      _check_length_equal(
          variable_assignments,
          model.variables,
          "variable_assignments",
          "model.variables",
      )
  
      self.model = model
  
      # The gradient log of probability distribution at position
      self.grad_log = None
  
      # The gradient log of probability distribution at position
      self.log_pdf = None
  
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 1 to create a new BaseGradLogPDF object from inherited base classes: object with example: obj = BaseGradLogPDF(variable_assignments, model)