def _aggregate_text_embedding(self, token_ids, embeddings):
    'Aggregate text embedding for a UI element.'
    if (self._hparams['obj_text_aggregation'] == 'max'):
        valid_token_mask = tf.greater_equal(token_ids, 4)
        invalid_token_bias = (tf.cast(tf.logical_not(valid_token_mask), tf.float32) * (- 1000000000.0))
        embeddings = (embeddings + tf.expand_dims(invalid_token_bias, axis=(- 1)))
        embeddings = tf.reduce_max(embeddings, axis=(- 2))
        valid_object_mask = tf.cast(tf.reduce_any(valid_token_mask, axis=(- 1)), tf.float32)
        embeddings = (embeddings * tf.expand_dims(valid_object_mask, axis=(- 1)))
    elif (self._hparams['obj_text_aggregation'] == 'sum'):
        real_objects = tf.cast(tf.greater_equal(token_ids, 4), tf.float32)
        embeddings = tf.reduce_sum(input_tensor=(embeddings * tf.expand_dims(real_objects, 3)), axis=(- 2))
    else:
        raise ValueError(('Unrecognized token aggregation %s' % self._hparams['obj_text_aggregation']))
    return embeddings
Aggregate text embedding for a UI element.
def _aggregate_text_embedding(self, token_ids, embeddings):
    
    if (self._hparams['obj_text_aggregation'] == 'max'):
        valid_token_mask = tf.greater_equal(token_ids, 4)
        invalid_token_bias = (tf.cast(tf.logical_not(valid_token_mask), tf.float32) * (- 1000000000.0))
        embeddings = (embeddings + tf.expand_dims(invalid_token_bias, axis=(- 1)))
        embeddings = tf.reduce_max(embeddings, axis=(- 2))
        valid_object_mask = tf.cast(tf.reduce_any(valid_token_mask, axis=(- 1)), tf.float32)
        embeddings = (embeddings * tf.expand_dims(valid_object_mask, axis=(- 1)))
    elif (self._hparams['obj_text_aggregation'] == 'sum'):
        real_objects = tf.cast(tf.greater_equal(token_ids, 4), tf.float32)
        embeddings = tf.reduce_sum(input_tensor=(embeddings * tf.expand_dims(real_objects, 3)), axis=(- 2))
    else:
        raise ValueError(('Unrecognized token aggregation %s' % self._hparams['obj_text_aggregation']))
    return embeddings