  
          # Sort them, to improve memory access pattern
          libcpp.algorithm.sort(indices.begin(), indices.end())
          for idx in indices:
              d_W = &self.d_W[idx * nr_class]
              for clas in range(nr_class):
                  if d_scores[clas] < 0:
                      d_W[clas] += max(-10., d_scores[clas])
                  else:
                      d_W[clas] += min(10., d_scores[clas])
  
      def finish_update(self, optimizer):
          cdef np.npy_intp[1] shape
          shape[0] = self.nr_weight * self.nr_class
          W_arr = np.PyArray_SimpleNewFromData(1, shape, np.NPY_FLOAT, self.W)
 
</s> remove         cdef np.npy_intp[1] shape
        shape[0] = self.nr_weight * self.nr_class
        W_arr = np.PyArray_SimpleNewFromData(1, shape, np.NPY_FLOAT, self.W)
        dW_arr = np.PyArray_SimpleNewFromData(1, shape, np.NPY_FLOAT, self.d_W)
        optimizer(W_arr, dW_arr, key=1)
 </s> add         pass </s> remove             W = &self.W[idx * nr_class]
 </s> add             W = &self.W[idx] </s> remove         pass
 </s> add         # Average weights
        for i in range(self.nr_weight * self.nr_class):  
            unchanged = self.time - self.last_upd[i]
            self.averages[i] += self.W[i] * unchanged
            self.W[i], self.averages[i] = self.averages[i], self.W[i]
            self.W[i] /= self.time
            self.last_upd[i] = self.time
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
  
          # Sort them, to improve memory access pattern
          libcpp.algorithm.sort(indices.begin(), indices.end())
          for idx in indices:
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
            #avg = &self.averages[idx]
            #last_upd = &self.last_upd[idx]
            W = &self.W[idx]
            #mom = &self.mom[idx]
            for i in range(nr_class):
                if d_scores[i] == 0:
                    continue
                d = d_scores[i]
                W[i] -= self.learn_rate * d
                #unchanged = self.time - last_upd[i]
                #avg[i] += unchanged * W[i]
                #mom[i] *= self.momentum ** unchanged
                #mom[i] += self.learn_rate * d
                #W[i] -= mom[i]
                #last_upd[i] = self.time
  
      def finish_update(self, optimizer):
          cdef np.npy_intp[1] shape
          shape[0] = self.nr_weight * self.nr_class
          W_arr = np.PyArray_SimpleNewFromData(1, shape, np.NPY_FLOAT, self.W)
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
 Play with hash kernel class 
spacy/_ml.pyx