//  [python]
def sample_instances(self, fc7_verbs, new_fc7_verbs_D_1, new_gt_class_HO_1, word2vec_list_D_1,
                         old_obj=None, new_obj=None, gen_num_clsses = 80,):
        with tf.device('/cpu:0'):
            word2vec_list_D_1 = tf.Print(word2vec_list_D_1,
                                         [tf.shape(word2vec_list_D_1), tf.shape(new_fc7_verbs_D_1), tf.reduce_sum(new_gt_class_HO_1)],
                                         'begin indexes:', first_n=100)
        conds = None
        new_ho_class_D_1 = new_gt_class_HO_1
        if self.network.model_name.__contains__('rands'):

            tmp_gt = tf.reshape(new_gt_class_HO_1, [-1, gen_num_clsses, self.network.compose_num_classes])
            print('==============', gen_num_clsses, self.obtain_last_verb_dim())
            new_fc7_verbs_D_1 = tf.reshape(new_fc7_verbs_D_1, [-1, gen_num_clsses, self.obtain_last_verb_dim()])
            word2vec_list_D_1 = tf.reshape(word2vec_list_D_1, [-1, gen_num_clsses, self.obtain_last_obj_dim()])


            noise = tf.random.uniform(shape=[gen_num_clsses, ], minval=0.00001, maxval=1.)
            noise = tf.expand_dims(noise, axis=0)
            noise = tf.expand_dims(noise, axis=-1)
            # N O HOI
            noise = tf.tile(noise, [tf.shape(tmp_gt)[0], 1, self.network.compose_num_classes])
            ll = tf.reduce_sum(tmp_gt, axis=-1)  # the number of labels for each composite HOI
            ll = tf.where(tf.equal(ll, 0), tf.ones_like(ll), ll)

            if self.network.model_name.__contains__('select'):
                # for ablated study
                # old_obj = tf.boolean_mask(old_obj, conds)
                # new_obj = tf.boolean_mask(new_obj, conds)
                neighbor_num = 40
                if self.network.model_name.__contains__('select10'):
                    neighbor_num = 10
                    pass
                elif self.network.model_name.__contains__('select1'):
                    neighbor_num = 1
                    pass
                elif self.network.model_name.__contains__('select5'):
                    neighbor_num = 5
                    pass
                elif self.network.model_name.__contains__('select20'):
                    neighbor_num = 20
                    pass
                elif self.network.model_name.__contains__('select40'):
                    neighbor_num = 40
                    pass
                elif self.network.model_name.__contains__('select80'):
                    neighbor_num = 80 #
                    pass
                tmp_conds_sim = self.get_wemb_mask(old_obj, new_obj, neighbor_num)
                sim_gt = tf.reshape(tmp_conds_sim, [-1, gen_num_clsses])
                sim_gt = tf.expand_dims(sim_gt, axis=-1)
                sim_gt = tf.tile(sim_gt, [1, 1, self.network.compose_num_classes])
                sim_gt = tf.cast(sim_gt, tf.float32)
                sim_gt = tf.multiply(sim_gt, tmp_gt) # filter out Dissimilar composite HOIs to original HOI
                noise = tf.reduce_sum(tf.multiply(sim_gt, noise), axis=-1) / ll
            else:
                print(tmp_gt, noise, '=========')
                noise = tf.reduce_sum(tf.multiply(tmp_gt, noise), axis=-1) / ll # remove zeros
                # is equal to : noise = tf.multiply(tf.cast(tf.reduce_sum(tmp_gt, axis=-1) > 0, tf.float32), tf.reduce_sum(noise, axis=-1)) / 600
                # here 600 does not matter
                # remove the noise whose corresponding gt label is zero.
            # N O
            select_num = 3
            indexes = tf.argsort(noise, axis=-1,  direction='DESCENDING', stable=True)[:, :select_num]
            print('=========DEBUG:indexes', indexes, )

            word2vec_list_D_1 = tf.batch_gather(word2vec_list_D_1, indexes)
            new_fc7_verbs_D_1 = tf.batch_gather(new_fc7_verbs_D_1, indexes)
            tmp_gt = tf.batch_gather(tmp_gt, indexes)

            new_fc7_verbs_D_1 = tf.reshape(new_fc7_verbs_D_1, [-1, self.obtain_last_verb_dim()])
            word2vec_list_D_1 = tf.reshape(word2vec_list_D_1, [-1, self.obtain_last_obj_dim()])
            new_ho_class_D_1 = tf.reshape(tmp_gt, [-1, self.network.compose_num_classes])

            new_gt_class_HO_1 = new_ho_class_D_1
            conds = tf.greater(tf.reduce_sum(new_ho_class_D_1, axis=-1), 0)

            with tf.device('/cpu:0'):
                word2vec_list_D_1 = tf.Print(word2vec_list_D_1,
                                             [tf.shape(noise), tf.shape(fc7_verbs), tf.shape(word2vec_list_D_1)],
                                             'randso indexes:', first_n=100)

        if conds is not None:
            print(conds, new_gt_class_HO_1, '==============================')
            word2vec_list_D_1 = tf.boolean_mask(word2vec_list_D_1, conds)
            new_fc7_verbs_D_1 = tf.boolean_mask(new_fc7_verbs_D_1, conds)
            new_ho_class_D_1 = tf.boolean_mask(new_gt_class_HO_1, conds)
            if old_obj is not None and new_obj is not None:
                old_obj = tf.boolean_mask(old_obj, conds)
                new_obj = tf.boolean_mask(new_obj, conds)
        with tf.device('/cpu:0'):
            word2vec_list_D_1 = tf.Print(word2vec_list_D_1,
                                         [tf.shape(word2vec_list_D_1), tf.shape(new_ho_class_D_1), tf.shape(new_gt_class_HO_1)],
                                         'begin2 indexes:', first_n=100)
        return new_fc7_verbs_D_1, new_ho_class_D_1, word2vec_list_D_1, old_obj, new_obj