import tensorflow as tf

            comb_ch = len(out_blocks) * block_ch
            X = tf.concat(out_blocks, axis=3)

        return (X, comb_ch)

    def _combine_cell_blocks_dynamic(self, cell_inputs, blocks, cell_arch, w, h, block_ch, is_train=False):
        ni = len(cell_inputs + blocks)
        b = len(blocks)

        # Count usage of inputs
        block_uses = []
        for bi in range(b):
            idx1 = cell_arch[bi][0]
            idx2 = cell_arch[bi][2]
            block_use = tf.one_hot(idx1, ni, dtype=tf.int32) + tf.one_hot(idx2, ni, dtype=tf.int32)
            block_uses.append(block_use)
        block_uses = tf.add_n(block_uses)
        unused_indices = tf.reshape(tf.cast(tf.where(tf.equal(block_uses, 0)), tf.int32), [-1])
        num_out_blocks = tf.size(unused_indices)

        # Select only unused blocks
        with tf.variable_scope('select'):
            stacked_blocks = tf.stack(cell_inputs + blocks)
            out_blocks = tf.gather(stacked_blocks, unused_indices, axis=0)
            out_blocks = tf.transpose(out_blocks, (1, 2, 3, 0, 4))

        # Combine to constant channels
        with tf.variable_scope('combine'):
