class_docstr: Initializer for XBNWriter class
  
  Parameters
  ----------
  model: BayesianNetwork Instance
      Model to write
  encoding: str(optional)
      Encoding for test data
  prettyprint: Bool(optional)
      Indentation in output XML if true
  
  Reference
  ---------
  http://xml.coverpages.org/xbn-MSdefault19990414.html
  
  Examples
  --------
  >>> writer = XBNWriter(model)
class_docstr_tok: ["Initializer","for","XBNWriter","class","Parameters","--","--","--","--","--","model",":","BayesianNetwork","Instance","Model","to","write","encoding",":","str","(","optional",")","Encoding","for","test","data","prettyprint",":","Bool","(","optional",")","Indentation","in","output","XML","if","true","Reference","--","--","--","--","-","http",":","\/\/xml.coverpages.org\/xbn-MSdefault19990414.html","Examples","--","--","--","--",">",">",">","writer","=","XBNWriter","(","model",")"]
docstr: Set distributions in the network.
  
  Examples
  --------
  >>> from pgmpy.readwrite.XMLBeliefNetwork import XBNWriter
  >>> writer =XBNWriter()
  >>> writer.set_distributions()
docstr_tok: ["Set","distributions","in","the","network",".","Examples","--","--","--","--",">",">",">","from","pgmpy.readwrite.XMLBeliefNetwork","import","XBNWriter",">",">",">","writer","=XBNWriter","(",")",">",">",">","writer.set_distributions","(",")"]
code: def set_distributions(self):
      """
      Set distributions in the network.
  
      Examples
      --------
      >>> from pgmpy.readwrite.XMLBeliefNetwork import XBNWriter
      >>> writer =XBNWriter()
      >>> writer.set_distributions()
      """
      distributions = etree.SubElement(self.bnmodel, "DISTRIBUTIONS")
  
      cpds = self.model.get_cpds()
      cpds.sort(key=lambda x: x.variable)
      for cpd in cpds:
          cpd_values = cpd.get_values().transpose()
          var = cpd.variable
          dist = etree.SubElement(
              distributions,
              "DIST",
              attrib={"TYPE": self.model.nodes[var]["TYPE"]},
          )
          etree.SubElement(dist, "PRIVATE", attrib={"NAME": var})
          dpis = etree.SubElement(dist, "DPIS")
          evidence = cpd.variables[1:]
          evidence_card = cpd.cardinality[1:]
          if evidence:
              condset = etree.SubElement(dist, "CONDSET")
              for condelem in evidence:
                  etree.SubElement(
                      condset, "CONDELEM", attrib={"NAME": condelem}
                  )
              indexes_iter = itertools.product(
                  *[range(card) for card in evidence_card]
              )
              for val in range(cpd_values.shape[0]):
                  index_value = (
                      " " + " ".join(map(str, next(indexes_iter))) + " "
                  )
                  etree.SubElement(
                      dpis, "DPI", attrib={"INDEXES": index_value}
                  ).text = (
                      " " + " ".join(map(str, cpd_values[val])) + " "
                  )
          else:
              etree.SubElement(dpis, "DPI").text = (
                  " " + " ".join(map(str, cpd_values[0])) + " "
              )
  
imports: import itertools
  import xml.etree.ElementTree
  import networkx
  import numpy
  from pgmpy.factors.discrete import TabularCPD
  from pgmpy.models import BayesianNetwork
label_desc: Use image node_id 9 for calling the XBNWriter obj's underlying member method code with example usage: obj.set_distributions() without return types