//  [python]
def _model_fn(self):
        # history embedding

        din_user_seq = tf.string_to_hash_bucket_fast(self.din_user_goods_seq, self.goods_bucket_size)
        din_target_id = tf.string_to_hash_bucket_fast(self.din_target_goods_id, self.goods_bucket_size)
        name = "goods"
        embedding_size = 8
        bucket_size = 1000

        print(self.din_user_goods_seq.get_shape())
        # batch_size = common_layer.get_shape().as_list()[0]
        # print(batch_size)
        max_his_len = 6
        # 序列长度sequence_length 需要减去值为-1的数，这里先统一成一样的
        # self.sequence_length = [max_his_len]*batch_size
        # self.sequence_length = max_his_len*tf.ones_like(self.labels)
        '''mask为值不为1的长度'''
        # numpy.zeros
        # self.mask = tf.ones_like(self.din_user_goods_seq,dtype=tf.int32)
        self.mask = tf.cast(tf.not_equal(self.din_user_goods_seq, '-1'),dtype=tf.int32)
        self.sequence_length = tf.reduce_sum(self.mask,-1)
        print(self.mask)

        with tf.variable_scope("seq_embedding_table" + name):
            embeddings = self.embedding_table(bucket_size, embedding_size, name)
            seq_emb = tf.nn.embedding_lookup(embeddings,
                                             din_user_seq)  # shape(batch_size, max_seq_len, embedding_size)
            u_his_emb = tf.reshape(seq_emb, shape=[-1, max_his_len,embedding_size])

            tid_emb = tf.nn.embedding_lookup(embeddings, din_target_id)

            if self.user_aux_loss:
                # din_user_seq   [batch_size,max_seq_len]

                tmp_seq = din_user_seq

                tmp_seq = tf.random.shuffle(tmp_seq,seed=1024)
                # tf.batch_gather/tf.gather/tf.gather_nd/
                # 打乱batch索引，用 tf.batch_gather() 取出数据。
                # tf.batch_gather()
                no_seq_emb = tf.nn.embedding_lookup(embeddings,
                                                 tmp_seq)
                # shape(batch_size, max_seq_len, embedding_size)
                self.noclk_u_his_emb = tf.reshape(no_seq_emb, shape=[-1, max_his_len, embedding_size])
                # x = u_his_emb.get_shape().as_list()[1]
                # y = u_his_emb.get_shape().as_list()[2]
                # print("x,y:", x, y)
                # tmp_his_emb = tf.reshape(u_his_emb, [-1, y])
                # tf.random.shuffle(tmp_his_emb)
                # noclk_u_his_emb = tf.reshape(tmp_his_emb, [-1, x, y])

        # RNN layer(-s)
        with tf.name_scope('rnn_1'):
            rnn_outputs, _ = dynamic_rnn(GRUCell(self.GRU_HIDDEN_SIZE), inputs=u_his_emb,
                                         sequence_length=self.sequence_length,
                                         dtype=tf.float32,
                                         scope="gru1")


        if self.user_aux_loss:
            # x = u_his_emb.get_shape().as_list()[1]
            # y = u_his_emb.get_shape().as_list()[2]
            # print("x,y:",x,y)
            # tmp_his_emb = tf.reshape(u_his_emb, [-1, y])
            # tf.random.shuffle(tmp_his_emb)
            # noclk_u_his_emb = tf.reshape(tmp_his_emb, [-1, x, y])
            #
            # print("asas",self.mask.get_shape().as_list())
            # print("dsds", self.din_user_goods_seq.get_shape().as_list())
            #
            # a = self.mask[:, 1:]
            # print("test case:")
            # print(a.get_shape().as_list())
            aux_loss_1 = self.auxiliary_loss(rnn_outputs[:, :-1, :], u_his_emb[:, 1:, :],
                                             self.noclk_u_his_emb[:, 1:, :],
                                             self.mask[:, 1:], stag="gru")
            self.aux_loss = aux_loss_1
            print("auc_loss:",self.aux_loss.get_shape().as_list())

        # Attention layer
        with tf.name_scope('Attention_layer_1'):
            att_outputs, alphas = self.din_fcn_attention(tid_emb, rnn_outputs, self.ATTENTION_SIZE, self.mask,
                                                         softmax_stag=1, stag='1_1', mode='LIST', return_alphas=True)
            tf.summary.histogram('alpha_outputs', alphas)

        with tf.name_scope('rnn_2'):
            rnn_outputs2, final_state2 = dynamic_rnn(VecAttGRUCell(self.GRU_HIDDEN_SIZE), inputs=rnn_outputs,
                                                     att_scores=tf.expand_dims(alphas, -1),
                                                     sequence_length=self.sequence_length, dtype=tf.float32,
                                                     scope="gru2")
            tf.summary.histogram('GRU2_Final_State', final_state2)
        # self.uid
        item_his_eb_sum = tf.reduce_sum(u_his_emb, 1)
        inp = tf.concat([self.embedding_layer, tid_emb, item_his_eb_sum, tid_emb * item_his_eb_sum, final_state2], 1)
        print("inp:",inp.get_shape())
        logits = self.fc_net(inp, last_num=1)
        return logits