code: def build_bbn(*args, **kwds):
      """Builds a BBN Graph from
      a list of functions and domains"""
      variables = set()
      domains = kwds.get("domains", {})
      name = kwds.get("name")
      factor_nodes = {}
  
      if isinstance(args[0], list):
          # Assume the functions were all
          # passed in a list in the first
          # argument. This makes it possible
          # to build very large graphs with
          # more than 255 functions, since
          # Python functions are limited to
          # 255 arguments.
          args = args[0]
  
      for factor in args:
          factor_args = get_args(factor)
          variables.update(factor_args)
          bbn_node = BBNNode(factor)
          factor_nodes[factor.__name__] = bbn_node
  
      # Now lets create the connections
      # To do this we need to find the
      # factor node representing the variables
      # in a child factors argument and connect
      # it to the child node.
  
      # Note that calling original_factors
      # here can break build_bbn if the
      # factors do not correctly represent
      # a BBN.
      original_factors = get_original_factors(
          list(factor_nodes.values())
      )
      for factor_node in list(factor_nodes.values()):
          factor_args = get_args(factor_node)
          parents = [
              original_factors[arg]
              for arg in factor_args
              if original_factors[arg] != factor_node
          ]
          for parent in parents:
              connect(parent, factor_node)
      bbn = BBN(original_factors, name=name)
      bbn.domains = domains
  
      return bbn
  
imports: import copy
  import heapq
  import logging
  from collections import defaultdict
  from io import StringIO
  from itertools import combinations, product
  from random import choice, random
  from .exceptions import VariableNotInGraphError, VariableValueNotInDomainError
  from .graph import Node, UndirectedGraph, UndirectedNode, connect
  from .utils import get_args, get_original_factors
label_desc: Use image node_id 2 for calling a global function with example usage: build_bbn() and returns: bbn