Training Physical Neural Networks for Analog In-Memory Computing