
Shared tensor plumbing behind every neural de_log_prob.* method
Source: R/density_estimator.R
de_log_prob_torch.RdCoerces theta and x to matrices, broadcasts a single-row x up to
theta's row count (the same broadcast lingauss_mean()'s caller does on
mu, just on the other operand), moves both to the net's device (see
net_device()), and evaluates log_prob_fn under with_no_grad().
log_prob_fn is the per-estimator tensor function –
mdn_log_prob_tensor(), maf_log_prob_tensor() or nsf_log_prob_tensor().
The result comes back to CPU before it leaves torch, so the rest of the
pipeline (and everything downstream of de_log_prob()) stays device-agnostic
plain R.