This paper focuses on applying Bayesian models from cognitive science to artificial intelligence. Specifically, based on predictive coding theory, we propose a model that explains learning and behavior through hierarchical probabilistic inference about the causes of sensory input. Considering biological realism, we utilize precision-weighted predictions and prediction errors based on simple local computations. To overcome the limitations of existing neural network libraries, we introduce pyhgf , a Python package based on JAX and Rust. pyhgf encapsulates network components as transparent, modular, and mutable variables during message passing, enabling the implementation of arbitrarily complex computations. Furthermore, adapting the network structure enables inference processes utilizing self-organization principles, structural learning, meta-learning, and causal inference.