refeactor learn and inference sampler