code: def build_sequence(self, xs, masks, init, is_left_to_right):
          '''
          Build GRU sequence.
          '''
          states = []
          last = init
          if is_left_to_right:
              for i, xs_i in enumerate(xs):
                  h = self.build(xs_i, last, masks[i])
                  states.append(h)
                  last = h
          else:
              for i in range(len(xs) - 1, -1, -1):
                  h = self.build(xs[i], last, masks[i])
                  states.insert(0, h)
                  last = h
          return statef build_sequence(self, xs, masks, init, is_left_to_right):
          '''
          Build GRU sequence.
          '''
          states = []
          last = init
          if is_left_to_right:
              for i, xs_i in enumerate(xs):
                  h = self.build(xs_i, last, masks[i])
                  states.append(h)
                  last = h
          else:
              for i in range(len(xs) - 1, -1, -1):
                  h = self.build(xs[i], last, masks[i])
                  states.insert(0, h)
                  last = h
          return states
docs: Build GRU sequence.