Identifying the formation mechanism of redback pulsars