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: This is belief-update method.
  
  Parameters
  ----------
  sending_clique: node (as the operation is on junction tree, node should be a tuple)
      Node sending the message
  receiving_clique: node (as the operation is on junction tree, node should be a tuple)
      Node receiving the message
  operation: str ('marginalize' | 'maximize')
      The operation to do for passing messages between nodes.
  
  Takes belief of one clique and uses it to update the belief of the
  neighboring ones.
docstr_tok: ["This","is","belief-update","method",".","Parameters","--","--","--","--","--","sending_clique",":","node","(","as","the","operation","is","on","junction","tree",",","node","should","be","a","tuple",")","Node","sending","the","message","receiving_clique",":","node","(","as","the","operation","is","on","junction","tree",",","node","should","be","a","tuple",")","Node","receiving","the","message","operation",":","str","(","'marginalize","'","|","'maximize","'",")","The","operation","to","do","for","passing","messages","between","nodes",".","Takes","belief","of","one","clique","and","uses","it","to","update","the","belief","of","the","neighboring","ones","."]
code: def _update_beliefs(
      self, sending_clique, receiving_clique, operation
  ):
      """
      This is belief-update method.
  
      Parameters
      ----------
      sending_clique: node (as the operation is on junction tree, node should be a tuple)
          Node sending the message
      receiving_clique: node (as the operation is on junction tree, node should be a tuple)
          Node receiving the message
      operation: str ('marginalize' | 'maximize')
          The operation to do for passing messages between nodes.
  
      Takes belief of one clique and uses it to update the belief of the
      neighboring ones.
      """
      sepset = frozenset(sending_clique).intersection(
          frozenset(receiving_clique)
      )
      sepset_key = frozenset((sending_clique, receiving_clique))
  
      # \sigma_{i \rightarrow j} = \sum_{C_i - S_{i, j}} \beta_i
      # marginalize the clique over the sepset
      sigma = getattr(self.clique_beliefs[sending_clique], operation)(
          list(frozenset(sending_clique) - sepset), inplace=False
      )
  
      # \beta_j = \beta_j * \frac{\sigma_{i \rightarrow j}}{\mu_{i, j}}
      self.clique_beliefs[receiving_clique] *= (
          sigma / self.sepset_beliefs[sepset_key]
          if self.sepset_beliefs[sepset_key]
          else sigma
      )
  
      # \mu_{i, j} = \sigma_{i \rightarrow j}
      self.sepset_beliefs[sepset_key] = sigma
  
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 5 for calling the BeliefPropagation obj's underlying member method code with example usage: obj._update_beliefs(sending_clique, receiving_clique, operation) without return types