  It is a recent realization that many of the concepts and tools of causal
discovery in machine learning are highly relevant to problems in quantum
information, in particular quantum nonlocality. The crucial ingredient in the
connection between both fields is the tool of Bayesian networks, a graphical
model used to reason about probabilistic causation. Indeed, Bell's theorem
concerns a particular kind of a Bayesian network and Bell inequalities are a
special case of linear constraints following from such models. It is thus
natural to look for generalized Bell scenarios involving more complex Bayesian
networks. The problem, however, relies on the fact that such generalized
scenarios are characterized by polynomial Bell inequalities and no current
method is available to derive them beyond very simple cases. In this work, we
make a significant step in that direction, providing a general and practical
method for the derivation of polynomial Bell inequalities in a wide class of
scenarios, applying it to a few cases of interest. We also show how our
construction naturally gives rise to a notion of non-signalling in generalized
networks.
