class_docstr: Class for performing Gibbs sampling.
  
  Parameters
  ----------
  model: BayesianNetwork or MarkovNetwork
      Model from which variables are inherited and transition probabilities computed.
  
  Examples
  --------
  Initialization from a BayesianNetwork object:
  
  >>> from pgmpy.factors.discrete import TabularCPD
  >>> from pgmpy.models import BayesianNetwork
  >>> intel_cpd = TabularCPD('intel', 2, [[0.7], [0.3]])
  >>> sat_cpd = TabularCPD('sat', 2, [[0.95, 0.2], [0.05, 0.8]], evidence=['intel'], evidence_card=[2])
  >>> student = BayesianNetwork()
  >>> student.add_nodes_from(['intel', 'sat'])
  >>> student.add_edge('intel', 'sat')
  >>> student.add_cpds(intel_cpd, sat_cpd)
  >>> from pgmpy.sampling import GibbsSampling
  >>> gibbs_chain = GibbsSampling(student)
  >>> gibbs_chain.sample(size=3)
     intel  sat
  0      0    0
  1      0    0
  2      1    1
class_docstr_tok: ["Class","for","performing","Gibbs","sampling",".","Parameters","--","--","--","--","--","model",":","BayesianNetwork","or","MarkovNetwork","Model","from","which","variables","are","inherited","and","transition","probabilities","computed",".","Examples","--","--","--","--","Initialization","from","a","BayesianNetwork","object",":",">",">",">","from","pgmpy.factors.discrete","import","TabularCPD",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","intel_cpd","=","TabularCPD","(","'intel","'",",","2",",","[","[","0.7","]",",","[","0.3","]","]",")",">",">",">","sat_cpd","=","TabularCPD","(","'sat","'",",","2",",","[","[","0.95",",","0.2","]",",","[","0.05",",","0.8","]","]",",","evidence=","[","'intel","'","]",",","evidence_card=","[","2","]",")",">",">",">","student","=","BayesianNetwork","(",")",">",">",">","student.add_nodes_from","(","[","'intel","'",",","'sat","'","]",")",">",">",">","student.add_edge","(","'intel","'",",","'sat","'",")",">",">",">","student.add_cpds","(","intel_cpd",",","sat_cpd",")",">",">",">","from","pgmpy.sampling","import","GibbsSampling",">",">",">","gibbs_chain","=","GibbsSampling","(","student",")",">",">",">","gibbs_chain.sample","(","size=3",")","intel","sat","0","0","0","1","0","0","2","1","1"]
code: def __init__(self, model=None):
      super(GibbsSampling, self).__init__()
      if isinstance(model, BayesianNetwork):
          self._get_kernel_from_bayesian_model(model)
      elif isinstance(model, MarkovNetwork):
          self._get_kernel_from_markov_model(model)
  
imports: import itertools
  from collections import namedtuple
  import networkx
  import numpy
  import pandas
  import torch
  from joblib import Parallel, delayed
  from tqdm.auto import tqdm
  from pgmpy import config
  from pgmpy.factors import factor_product
  from pgmpy.models import BayesianNetwork, MarkovChain, MarkovNetwork
  from pgmpy.sampling import BayesianModelInference, _return_samples
  from pgmpy.utils.mathext import sample_discrete, sample_discrete_maps
label_desc: Use image node_id 1 to create a new GibbsSampling object from inherited base classes: MarkovChain with example: obj = GibbsSampling(model)