      X = ops.flatten(seqs, pad=pad)
      return (X, lengths), finish_update
  
  
  @layerize
  def _logistic(X, drop=0.):
      xp = get_array_module(X)
      if not isinstance(X, xp.ndarray):
          X = xp.asarray(X)
      # Clip to range (-10, 10)
      X = xp.minimum(X, 10., X)
      X = xp.maximum(X, -10., X)
      Y = 1. / (1. + xp.exp(-X))
  
      def logistic_bwd(dY, sgd=None):
          dX = dY * (Y * (1-Y))
          return dX
  
      return Y, logistic_bwd
  
  
  def _zero_init(model):
      def _zero_init_impl(self, X, y):
          self.W.fill(0)
      model.on_data_hooks.append(_zero_init_impl)
      if model.W is not None:
 
</s> remove         Yf = self.ops.xp.dot(X,
            self.W.reshape((self.nF*self.nO*self.nP, self.nI)).T)
 </s> add         Yf = self.ops.gemm(X,
            self.W.reshape((self.nF*self.nO*self.nP, self.nI)), trans2=True) </s> remove         cdef float feature
        while not state.is_final():
            state.set_context_tokens(token_ids, nr_feat)
            memset(vectors, 0, nr_hidden * nr_piece * sizeof(float))
            memset(scores, 0, nr_class * sizeof(float))
            sum_state_features(vectors,
                feat_weights, token_ids, 1, nr_feat, nr_hidden * nr_piece)
            for i in range(nr_hidden * nr_piece):
                vectors[i] += bias[i]
            V = vectors
            W = hW
            for i in range(nr_hidden):
                if nr_piece == 1:
                    feature = V[0] if V[0] >= 0. else 0.
                elif nr_piece == 2:
                    feature = V[0] if V[0] >= V[1] else V[1]
                else:
                    feature = Vec.max(V, nr_piece)
                for j in range(nr_class):
                    scores[j] += feature * W[j]
                W += nr_class
                V += nr_piece
            for i in range(nr_class):
                scores[i] += hb[i]
            self.moves.set_valid(is_valid, state)
            guess = arg_max_if_valid(scores, is_valid, nr_class)
            action = self.moves.c[guess]
            action.do(state, action.label)
            state.push_hist(guess)
 </s> add         cdef int nr_todo = nr_task
        cdef int i, j
        cdef vector[StateC*] unfinished
        while nr_todo >= 1:
            memset(vectors, 0, nr_todo * nr_hidden * sizeof(float))
            memset(scores, 0, nr_todo * nr_class * sizeof(float))
            for i in range(nr_todo):
                state = states[i]
                state.set_context_tokens(token_ids, nr_feat)
                memset(unmaxed, 0, nr_hidden * nr_piece * sizeof(float))
                sum_state_features(unmaxed,
                    feat_weights, token_ids, 1, nr_feat, nr_hidden * nr_piece)
                VecVec.add_i(unmaxed,
                    bias, 1., nr_hidden*nr_piece)
                state_vector = &vectors[i*nr_hidden]
                for j in range(nr_hidden):
                    index = j * nr_piece
                    which = Vec.arg_max(&unmaxed[index], nr_piece)
                    state_vector[j] = unmaxed[index + which]
            # Compute hidden-to-output
            openblas.simple_gemm(scores, nr_todo, nr_class,
                vectors, nr_todo, nr_hidden, hW, nr_hidden, nr_class, 0, 0)
            # Add bias
            for i in range(nr_todo):
                VecVec.add_i(&scores[i*nr_class],
                    hb, 1., nr_class)
            # Validate actions, argmax, take action.
            for i in range(nr_todo):
                state = states[i]
                self.moves.set_valid(is_valid, state)
                guess = arg_max_if_valid(&scores[i*nr_class], is_valid, nr_class)
                action = self.moves.c[guess]
                action.do(state, action.label)
                state.push_hist(guess)
                if not state.is_final():
                    unfinished.push_back(state)
            for i in range(unfinished.size()):
                states[i] = unfinished[i]
            nr_todo = unfinished.size()
            unfinished.clear() </s> remove         with loc.open('r', encoding='utf8') as file_:
            docs = ujson.load(file_)
        if limit is not None:
            docs = docs[:limit]
        for doc in docs:
 </s> add         for doc in _json_iterate(loc): </s> remove         self.cand_to_gold = align([t.orth_ for t in doc], words)
        self.gold_to_cand = align(words, [t.orth_ for t in doc])
 </s> add         # This needs to be done before we align the words
        if make_projective and heads is not None and deps is not None:
            heads, deps = nonproj.projectivize(heads, deps)

        # Do many-to-one alignment for misaligned tokens.
        # If we over-segment, we'll have one gold word that covers a sequence
        # of predicted words
        # If we under-segment, we'll have one predicted word that covers a
        # sequence of gold words.
        # If we "mis-segment", we'll have a sequence of predicted words covering
        # a sequence of gold words. That's many-to-many -- we don't do that.
        cost, i2j, j2i, i2j_multi, j2i_multi = align([t.orth_ for t in doc], words)

        self.cand_to_gold = [(j if j >= 0 else None) for j in i2j]
        self.gold_to_cand = [(i if i >= 0 else None) for i in j2i] </s> remove     @property
    def train_tuples(self):
 </s> add         # Write temp directory with one doc per file, so we can shuffle
        # and stream
        self.tmp_dir = Path(tempfile.mkdtemp())
        self.write_msgpack(self.tmp_dir / 'train', train)
        self.write_msgpack(self.tmp_dir / 'dev', dev)

    def __del__(self):
        shutil.rmtree(self.tmp_dir)

    @staticmethod
    def write_msgpack(directory, doc_tuples):
        if not directory.exists():
            directory.mkdir()
        for i, doc_tuple in enumerate(doc_tuples):
            with open(directory / '{}.msg'.format(i), 'wb') as file_:
                msgpack.dump([doc_tuple], file_, use_bin_type=True, encoding='utf8')
    
    @staticmethod
    def walk_corpus(path):
        path = util.ensure_path(path)
        if not path.is_dir():
            return [path]
        paths = [path]
        locs = []
        seen = set()
        for path in paths:
            if str(path) in seen:
                continue
            seen.add(str(path))
            if path.parts[-1].startswith('.'):
                continue
            elif path.is_dir():
                paths.extend(path.iterdir())
            elif path.parts[-1].endswith('.json'):
                locs.append(path)
        return locs

    @staticmethod
    def read_tuples(locs, limit=0):
      X = ops.flatten(seqs, pad=pad)
      return (X, lengths), finish_update
  
  

















  def _zero_init(model):
      def _zero_init_impl(self, X, y):
          self.W.fill(0)
      model.on_data_hooks.append(_zero_init_impl)
      if model.W is not None:
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Revert "Merge branch 'develop' of https://github.com/explosion/spaCy into develop"

This reverts commit c9ba3d3c2dc7067cf8bd55f878cec45a8c6d73d4, reversing
changes made to 92c26a35d425d4e8ca1b805ea776ea10f5ded3df. 
spacy/_ml.py