code: def _bag_of_words(x):
    
    def _bow(x):
      """Comptue BOW weights.
  
      As tf layer's sum combiner is used, the weights can be just ones. Tokens are
      not summed together here.
      """
      return tf.SparseTensor(
        indices=x.indices,
        values=tf.to_float(tf.ones_like(x.values)),
        dense_shape=x.dense_shape)
  
    return _bow(x)
docs: Computes bag of words weights
  
    Note the return type is a float sparse tensor, not a int sparse tensor. This
    is so that the output types batch tfidf, and any downstream transformation
    in tf layers during training can be applied to both.