<commit_before>#pragma once

#include "models/s2s.h"
#include "models/encdec.h"

namespace marian {

struct EncoderStateMultiS2S : public EncoderState {
  EncoderStateMultiS2S(Ptr<EncoderState> e1, Ptr<EncoderState> e2)
  : enc1(e1), enc2(e2) {}
  
  virtual Expr getContext() { return nullptr; }
  virtual Expr getMask() { return nullptr; }

  Ptr<EncoderState> enc1;
  Ptr<EncoderState> enc2;
};

class DecoderStateMultiS2S : public DecoderState {
  private:
    std::vector<Expr> states_;
    Expr probs_;
    Ptr<EncoderState> encState_;
    
  public:
    DecoderStateMultiS2S(const std::vector<Expr> states,
                         Expr probs,
                         Ptr<EncoderState> encState)
    : states_(states), probs_(probs), encState_(encState) {}
    
    
    Ptr<EncoderState> getEncoderState() { return encState_; }
    Expr getProbs() { return probs_; }
    void setProbs(Expr probs) { probs_ = probs; }
    
    Ptr<DecoderState> select(const std::vector<size_t>& selIdx) {
      int numSelected = selIdx.size();
      int dimState = states_[0]->shape()[1];
      
      std::vector<Expr> selectedStates;
      for(auto state : states_) {
        selectedStates.push_back(
          reshape(rows(state, selIdx),
                  {1, dimState, 1, numSelected})
        );
      }
      
      return New<DecoderStateMultiS2S>(selectedStates, probs_, encState_);
    }

    
    const std::vector<Expr>& getStates() { return states_; }
};

template <class Encoder1, class Encoder2>
class MultiEncoder : public EncoderBase {
  private:
    Ptr<Encoder1> encoder1_;
    Ptr<Encoder2> encoder2_;

  public:
    template <class ...Args>
    MultiEncoder(Ptr<Config> options, Args ...args)
     : EncoderBase(options, args...),
       encoder1_(New<Encoder1>(options, keywords::prefix="encoder1", args...)),
       encoder2_(New<Encoder2>(options, keywords::prefix="encoder2", args...)) {}

    Ptr<EncoderState>
    build(Ptr<ExpressionGraph> graph,
          Ptr<data::CorpusBatch> batch,
          size_t batchIdx = 0) {

      auto encState1 = encoder1_->build(graph, batch, 0);
      auto encState2 = encoder2_->build(graph, batch, 1);

      return New<EncoderStateMultiS2S>(encState1, encState2);
    }
};

template <class Cell1, class Attention1, class Attention2, class Cell2>
class MultiAttentionCell {
  private:
    Ptr<Cell1> cell1_;
    Ptr<Cell2> cell2_;<commit_msg>typedef for multis2s decoder state<commit_after>#pragma once

#include "models/s2s.h"
#include "models/encdec.h"

namespace marian {

struct EncoderStateMultiS2S : public EncoderState {
  EncoderStateMultiS2S(Ptr<EncoderState> e1, Ptr<EncoderState> e2)
  : enc1(e1), enc2(e2) {}
  
  virtual Expr getContext() { return nullptr; }
  virtual Expr getMask() { return nullptr; }

  Ptr<EncoderState> enc1;
  Ptr<EncoderState> enc2;
};

typedef DecoderStateS2S DecoderStateMultiS2S;

template <class Encoder1, class Encoder2>
class MultiEncoder : public EncoderBase {
  private:
    Ptr<Encoder1> encoder1_;
    Ptr<Encoder2> encoder2_;

  public:
    template <class ...Args>
    MultiEncoder(Ptr<Config> options, Args ...args)
     : EncoderBase(options, args...),
       encoder1_(New<Encoder1>(options, keywords::prefix="encoder1", args...)),
       encoder2_(New<Encoder2>(options, keywords::prefix="encoder2", args...)) {}

    Ptr<EncoderState>
    build(Ptr<ExpressionGraph> graph,
          Ptr<data::CorpusBatch> batch,
          size_t batchIdx = 0) {

      auto encState1 = encoder1_->build(graph, batch, 0);
      auto encState2 = encoder2_->build(graph, batch, 1);

      return New<EncoderStateMultiS2S>(encState1, encState2);
    }
};

template <class Cell1, class Attention1, class Attention2, class Cell2>
class MultiAttentionCell {
  private:
    Ptr<Cell1> cell1_;
    Ptr<Cell2> cell2_;
{'fraction_non_alphanumeric': 0.122336227308603, 'fraction_numerical': 0.024204156800841883, 'mean_word_length': 3.488783943329398, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2189459', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1219, 'n_words': 270}