Statistical **data** analysis in the natural sciences is most often founded on a probabilistic modelling of the underlying data-generating process, where p(x|θ) denotes the probability of experimentally observing **data** x given a set of theory parameters θ. Inference aims at assessing the theory space in light of the observed **data** in order to estimate points or intervals in this space that are compatible with the **data** as well as test hypotheses for data-driven decision-making. In frequentist statistics the main tools for these tasks are estimates based on the well-developed methodology of maximum-likelihood estimation, confidence intervals construction and test statistics. In a Bayesian context, most inference tasks derive their results from methods that aim to compute posterior densities of the form p(θ|x). A major problem for both approaches, however, are likelihood-free settings, i.e. experimental situations where samples x ∼ p(x|θ) are available but evaluating the likelihood p(x|θ) is computationally intractable. The field of likelihood-free inference thus aims to develop methods that allow us to still perform the desired inference tasks without requiring explicit evaluation of the model. High-Energy Physics **data** analysis is a prominent example of such a likelihood-free problem, which appears due to a rich, but unobservable evolution of the original particle collision through many latent intermediate states z i culminating into a high-dimensional measurement x. While the evolution probability itself is p(x, z|θ) is tractable, the model of the observable **data** p(x|θ) = dz p(x, z|θ) is not. Classical approaches to likelihood-free inference often use simulation and summary statistics f (x) to derive a low-dimensional approximate model p(f (x)|θ) to which the standard methodology can then be applied. More recently a new breed of methods are developed that aim to use machine learning to eschew an explicit approximation of the statistical model, in favor of directly targeting only the model-derived quantities required for inference. In this work we add to this program by presenting a method to learn a test statistic with best average power. For models which lie in the asymptotic regime, this is equivalent to the profile likelihood ratio test statistic, which is a key quantity in frequentist **data** analysis for models that incorporate systematic uncertainties through nuisance parameters.