def single_inference_run()

in src/lic/ppl/inference/abstract_mh_infer.py [0:0]


    def single_inference_run(self, node: RVIdentifier, proposer) -> Tuple[bool, Tensor]:
        """
        Run one iteration of the inference algorithms for a given node which is
        to follow the steps below:
        1) Propose a new value for the node
        2) Update the world given the new value
        3) Compute the log proposal ratio of proposing this value
        4) Accept or reject the proposed value

        :param node: the node to be re-sampled in this inference run
        :param proposer: the proposer with which propose a new value for node
        :returns: acceptance probability for the query
        """
        (
            proposed_value,
            negative_proposal_log_update,
            auxiliary_variables,
        ) = proposer.propose(node, self.world_)

        LOGGER_INFERENCE.log(
            LogLevel.DEBUG_UPDATES.value,
            "=" * 30
            + "\n"
            + "Node: {n}\n".format(n=node)
            + "- Node value: {nv}\n".format(
                # pyre-fixme
                nv=self.world_.get_node_in_world(node, False, False).value
            )
            + "- Proposed value: {pv}\n".format(pv=proposed_value),
        )

        children_log_updates, _, node_log_update, _ = self.world_.propose_change(
            node, proposed_value
        )
        positive_proposal_log_update = proposer.post_process(
            node, self.world_, auxiliary_variables
        )
        proposal_log_update = (
            positive_proposal_log_update + negative_proposal_log_update
        )
        is_accepted, acceptance_probability = self.accept_or_reject_update(
            node_log_update, children_log_updates, proposal_log_update
        )

        return is_accepted, acceptance_probability