class_docstr: Class for performing inference using Belief Propagation method.
  
  Creates a Junction Tree or Clique Tree (JunctionTree class) for the input
  probabilistic graphical model and performs calibration of the junction tree
  so formed using belief propagation.
  
  Parameters
  ----------
  model: BayesianNetwork, MarkovNetwork, FactorGraph, JunctionTree
      model for which inference is to performed
docstr: Max-calibration of the junction tree using belief propagation.
  
  Examples
  --------
  >>> from pgmpy.models import BayesianNetwork
  >>> from pgmpy.factors.discrete import TabularCPD
  >>> from pgmpy.inference import BeliefPropagation
  >>> G = BayesianNetwork([('diff', 'grade'), ('intel', 'grade'),
  ...                    ('intel', 'SAT'), ('grade', 'letter')])
  >>> diff_cpd = TabularCPD('diff', 2, [[0.2], [0.8]])
  >>> intel_cpd = TabularCPD('intel', 3, [[0.5], [0.3], [0.2]])
  >>> grade_cpd = TabularCPD('grade', 3,
  ...                        [[0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
  ...                         [0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
  ...                         [0.8, 0.8, 0.8, 0.8, 0.8, 0.8]],
  ...                        evidence=['diff', 'intel'],
  ...                        evidence_card=[2, 3])
  >>> sat_cpd = TabularCPD('SAT', 2,
  ...                      [[0.1, 0.2, 0.7],
  ...                       [0.9, 0.8, 0.3]],
  ...                      evidence=['intel'], evidence_card=[3])
  >>> letter_cpd = TabularCPD('letter', 2,
  ...                         [[0.1, 0.4, 0.8],
  ...                          [0.9, 0.6, 0.2]],
  ...                         evidence=['grade'], evidence_card=[3])
  >>> G.add_cpds(diff_cpd, intel_cpd, grade_cpd, sat_cpd, letter_cpd)
  >>> bp = BeliefPropagation(G)
  >>> bp.max_calibrate()
docstr_tok: ["Max-calibration","of","the","junction","tree","using","belief","propagation",".","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","from","pgmpy.factors.discrete","import","TabularCPD",">",">",">","from","pgmpy.inference","import","BeliefPropagation",">",">",">","G","=","BayesianNetwork","(","[","(","'diff","'",",","'grade","'",")",",","(","'intel","'",",","'grade","'",")",",","...","(","'intel","'",",","'SAT","'",")",",","(","'grade","'",",","'letter","'",")","]",")",">",">",">","diff_cpd","=","TabularCPD","(","'diff","'",",","2",",","[","[","0.2","]",",","[","0.8","]","]",")",">",">",">","intel_cpd","=","TabularCPD","(","'intel","'",",","3",",","[","[","0.5","]",",","[","0.3","]",",","[","0.2","]","]",")",">",">",">","grade_cpd","=","TabularCPD","(","'grade","'",",","3",",","...","[","[","0.1",",","0.1",",","0.1",",","0.1",",","0.1",",","0.1","]",",","...","[","0.1",",","0.1",",","0.1",",","0.1",",","0.1",",","0.1","]",",","...","[","0.8",",","0.8",",","0.8",",","0.8",",","0.8",",","0.8","]","]",",","...","evidence=","[","'diff","'",",","'intel","'","]",",","...","evidence_card=","[","2",",","3","]",")",">",">",">","sat_cpd","=","TabularCPD","(","'SAT","'",",","2",",","...","[","[","0.1",",","0.2",",","0.7","]",",","...","[","0.9",",","0.8",",","0.3","]","]",",","...","evidence=","[","'intel","'","]",",","evidence_card=","[","3","]",")",">",">",">","letter_cpd","=","TabularCPD","(","'letter","'",",","2",",","...","[","[","0.1",",","0.4",",","0.8","]",",","...","[","0.9",",","0.6",",","0.2","]","]",",","...","evidence=","[","'grade","'","]",",","evidence_card=","[","3","]",")",">",">",">","G.add_cpds","(","diff_cpd",",","intel_cpd",",","grade_cpd",",","sat_cpd",",","letter_cpd",")",">",">",">","bp","=","BeliefPropagation","(","G",")",">",">",">","bp.max_calibrate","(",")"]
code: def max_calibrate(self):
      """
      Max-calibration of the junction tree using belief propagation.
  
      Examples
      --------
      >>> from pgmpy.models import BayesianNetwork
      >>> from pgmpy.factors.discrete import TabularCPD
      >>> from pgmpy.inference import BeliefPropagation
      >>> G = BayesianNetwork([('diff', 'grade'), ('intel', 'grade'),
      ...                    ('intel', 'SAT'), ('grade', 'letter')])
      >>> diff_cpd = TabularCPD('diff', 2, [[0.2], [0.8]])
      >>> intel_cpd = TabularCPD('intel', 3, [[0.5], [0.3], [0.2]])
      >>> grade_cpd = TabularCPD('grade', 3,
      ...                        [[0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
      ...                         [0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
      ...                         [0.8, 0.8, 0.8, 0.8, 0.8, 0.8]],
      ...                        evidence=['diff', 'intel'],
      ...                        evidence_card=[2, 3])
      >>> sat_cpd = TabularCPD('SAT', 2,
      ...                      [[0.1, 0.2, 0.7],
      ...                       [0.9, 0.8, 0.3]],
      ...                      evidence=['intel'], evidence_card=[3])
      >>> letter_cpd = TabularCPD('letter', 2,
      ...                         [[0.1, 0.4, 0.8],
      ...                          [0.9, 0.6, 0.2]],
      ...                         evidence=['grade'], evidence_card=[3])
      >>> G.add_cpds(diff_cpd, intel_cpd, grade_cpd, sat_cpd, letter_cpd)
      >>> bp = BeliefPropagation(G)
      >>> bp.max_calibrate()
      """
      self._calibrate_junction_tree(operation="maximize")
  
imports: import copy
  import itertools
  import networkx
  import numpy
  from opt_einsum import contract
  from tqdm.auto import tqdm
  from pgmpy import config
  from pgmpy.factors import factor_product
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.inference import Inference
  from pgmpy.inference.EliminationOrder import MinFill, MinNeighbors, MinWeight, WeightedMinFill
  from pgmpy.models import BayesianNetwork, DynamicBayesianNetwork, JunctionTree, MarkovNetwork
  from pgmpy.utils import compat_fns
label_desc: Use image node_id 9 for calling the BeliefPropagation obj's underlying member method code with example usage: obj.max_calibrate() without return types