def __init__(self, opt, dictionary):
    super().__init__()
    self.opt = opt
    self.pad_idx = dictionary[dictionary.null_token]
    self.scores_norm = opt['scores_norm']
    self.embeddings = _create_embeddings(dictionary, opt['embedding_size'], self.pad_idx)
    self.context_encoder = _build_encoder(opt, dictionary, self.embeddings, self.pad_idx)
    if opt.get('share_encoders'):
        self.cand_encoder = TransformerResponseWrapper(self.context_encoder, self.context_encoder.out_dim, reduction=True)
    else:
        self.cand_encoder = _build_encoder(opt, dictionary, self.embeddings, self.pad_idx, reduction=True)
    if opt.get('wrap_memory_encoder', False):
        self.memory_transformer = TransformerResponseWrapper(self.context_encoder, self.context_encoder.out_dim)
    else:
        self.memory_transformer = self.context_encoder
    self.attender = BasicAttention(dim=2, attn=opt['memory_attention'])
def __init__(self, opt, dictionary):
    super().__init__()
    self.opt = opt
    self.pad_idx = dictionary[dictionary.null_token]
    self.scores_norm = opt['scores_norm']
    self.embeddings = _create_embeddings(dictionary, opt['embedding_size'], self.pad_idx)
    self.context_encoder = _build_encoder(opt, dictionary, self.embeddings, self.pad_idx)
    if opt.get('share_encoders'):
        self.cand_encoder = TransformerResponseWrapper(self.context_encoder, self.context_encoder.out_dim, reduction=True)
    else:
        self.cand_encoder = _build_encoder(opt, dictionary, self.embeddings, self.pad_idx, reduction=True)
    if opt.get('wrap_memory_encoder', False):
        self.memory_transformer = TransformerResponseWrapper(self.context_encoder, self.context_encoder.out_dim)
    else:
        self.memory_transformer = self.context_encoder
    self.attender = BasicAttention(dim=2, attn=opt['memory_attention'])