Implantable neurostimulators for stimulating central or peripheral nerve system