Fixed divison by zero bug in DistanceWeightedSampling in gluon example (#10857)
Fixed divison by zero bug in DistanceWeightedSampling in gluon example (#10857)

* Fixed divison by zero bug in DistanceWeightedSampling in gluon example

Sample selection for training is based on a vector of computed probablities that come from distance weights. In the current implementation these weights can become zero when distance to all other neightbors is zero.
Zero weights lead to nan bugs in the model, this commit is supposed to fix it by changing those zero weights not being divided by zero any longer.

* Reworked how np.choice is invoked in DistanceWeightedSampling to avoid a try-except closure

* Added an early return to MarginLoss if loss becomes zero.

* Rewrote MargingLoss so it is hybridizable

reminisce/mxnet,mbaijal/incubator-mxnet,navrasio/mxnet,szha/mxnet,ptrendx/mxnet,zhreshold/mxnet,indhub/mxnet,precedenceguo/mxnet,reminisce/mxnet,DickJC123/mxnet,mbaijal/incubator-mxnet,dmlc/mxnet,zhreshold/mxnet,jamesliu/mxnet,navrasio/mxnet,yajiedesign/mxnet,indhub/mxnet,tlby/mxnet,zhreshold/mxnet,precedenceguo/mxnet,precedenceguo/mxnet,rahul003/mxnet,eric-haibin-lin/mxnet,yajiedesign/mxnet,tlby/mxnet,tlby/mxnet,szha/mxnet,mbaijal/incubator-mxnet,eric-haibin-lin/mxnet,rahul003/mxnet,sxjscience/mxnet,larroy/mxnet,rahul003/mxnet,szha/mxnet,ForkedReposBak/mxnet,eric-haibin-lin/mxnet,leezu/mxnet,precedenceguo/mxnet,jamesliu/mxnet,ptrendx/mxnet,reminisce/mxnet,szha/mxnet,ForkedReposBak/mxnet,zhreshold/mxnet,dmlc/mxnet,tlby/mxnet,leezu/mxnet,ptrendx/mxnet,tlby/mxnet,larroy/mxnet,ptrendx/mxnet,DickJC123/mxnet,indhub/mxnet,eric-haibin-lin/mxnet,navrasio/mxnet,jamesliu/mxnet,jamesliu/mxnet,sxjscience/mxnet,precedenceguo/mxnet,larroy/mxnet,yajiedesign/mxnet,jamesliu/mxnet,mbaijal/incubator-mxnet,rahul003/mxnet,rahul003/mxnet,leezu/mxnet,precedenceguo/mxnet,jamesliu/mxnet,eric-haibin-lin/mxnet,reminisce/mxnet,sxjscience/mxnet,navrasio/mxnet,leezu/mxnet,yajiedesign/mxnet,indhub/mxnet,precedenceguo/mxnet,ForkedReposBak/mxnet,precedenceguo/mxnet,reminisce/mxnet,szha/mxnet,eric-haibin-lin/mxnet,szha/mxnet,rahul003/mxnet,ptrendx/mxnet,sxjscience/mxnet,reminisce/mxnet,indhub/mxnet,mbaijal/incubator-mxnet,zhreshold/mxnet,ptrendx/mxnet,leezu/mxnet,ptrendx/mxnet,leezu/mxnet,reminisce/mxnet,dmlc/mxnet,ForkedReposBak/mxnet,larroy/mxnet,eric-haibin-lin/mxnet,apache/incubator-mxnet,indhub/mxnet,dmlc/mxnet,ForkedReposBak/mxnet,navrasio/mxnet,indhub/mxnet,zhreshold/mxnet,navrasio/mxnet,yajiedesign/mxnet,leezu/mxnet,szha/mxnet,rahul003/mxnet,mbaijal/incubator-mxnet,dmlc/mxnet,reminisce/mxnet,leezu/mxnet,rahul003/mxnet,indhub/mxnet,DickJC123/mxnet,dmlc/mxnet,ForkedReposBak/mxnet,eric-haibin-lin/mxnet,tlby/mxnet,navrasio/mxnet,larroy/mxnet,zhreshold/mxnet,indhub/mxnet,tlby/mxnet,mbaijal/incubator-mxnet,sxjscience/mxnet,navrasio/mxnet,tlby/mxnet,yajiedesign/mxnet,zhreshold/mxnet,zhreshold/mxnet,ForkedReposBak/mxnet,larroy/mxnet,mbaijal/incubator-mxnet,yajiedesign/mxnet,tlby/mxnet,szha/mxnet,apache/incubator-mxnet,apache/incubator-mxnet,larroy/mxnet,eric-haibin-lin/mxnet,leezu/mxnet,mbaijal/incubator-mxnet,precedenceguo/mxnet,dmlc/mxnet,szha/mxnet,jamesliu/mxnet,ptrendx/mxnet,larroy/mxnet,reminisce/mxnet,sxjscience/mxnet,rahul003/mxnet,dmlc/mxnet,yajiedesign/mxnet,sxjscience/mxnet,jamesliu/mxnet,navrasio/mxnet,DickJC123/mxnet,sxjscience/mxnet,tlby/mxnet,jamesliu/mxnet,ForkedReposBak/mxnet,reminisce/mxnet,sxjscience/mxnet,dmlc/mxnet,apache/incubator-mxnet,ptrendx/mxnet,yajiedesign/mxnet,ForkedReposBak/mxnet,ptrendx/mxnet,larroy/mxnet