parameters: (ids,
                  vocab_size,
                  embed_dim,
                  sparse_lookup=True,
                  initializer=None,
                  regularizer=None,
                  trainable=True,
                  scope=None,
                  reuse=None)
docstring: Maps a sequence of symbols to a vector per example by averaging embeddings.
  
    Args:
      ids: `[batch_size, doc_length]` `Tensor` or `SparseTensor` of type
        `int32` or `int64` with symbol ids.
      vocab_size: Integer number of symbols in vocabulary.
      embed_dim: Integer number of dimensions for embedding matrix.
      sparse_lookup: `bool`, if `True`, converts ids to a `SparseTensor`
          and performs a sparse embedding lookup. This is usually faster,
          but not desirable if padding tokens should have an embedding. Empty rows
          are assigned a special embedding.
      initializer: An initializer for the embeddings, if `None` default for
          current scope is used.
      regularizer: Optional regularizer for the embeddings.
      trainable: If `True` also add variables to the graph collection
        `GraphKeys.TRAINABLE_VARIABLES` (see tf.Variable).
      scope: Optional string specifying the variable scope for the op, required
          if `reuse=True`.
      reuse: If `True`, variables inside the op will be reused.
  
    Returns:
      Encoding `Tensor` `[batch_size, embed_dim]` produced by
      averaging embeddings.
  
    Raises:
      ValueError: If `embed_dim` or `vocab_size` are not specified.
docstring_summary: Maps a sequence of symbols to a vector per example by averaging embeddings.
docstring_tokens: Maps a sequence of symbols to a vector per example by averaging embeddings .
function: def bow_encoder(ids,
                  vocab_size,
                  embed_dim,
                  sparse_lookup=True,
                  initializer=None,
                  regularizer=None,
                  trainable=True,
                  scope=None,
                  reuse=None):
    """Maps a sequence of symbols to a vector per example by averaging embeddings.
  
    Args:
      ids: `[batch_size, doc_length]` `Tensor` or `SparseTensor` of type
        `int32` or `int64` with symbol ids.
      vocab_size: Integer number of symbols in vocabulary.
      embed_dim: Integer number of dimensions for embedding matrix.
      sparse_lookup: `bool`, if `True`, converts ids to a `SparseTensor`
          and performs a sparse embedding lookup. This is usually faster,
          but not desirable if padding tokens should have an embedding. Empty rows
          are assigned a special embedding.
      initializer: An initializer for the embeddings, if `None` default for
          current scope is used.
      regularizer: Optional regularizer for the embeddings.
      trainable: If `True` also add variables to the graph collection
        `GraphKeys.TRAINABLE_VARIABLES` (see tf.Variable).
      scope: Optional string specifying the variable scope for the op, required
          if `reuse=True`.
      reuse: If `True`, variables inside the op will be reused.
  
    Returns:
      Encoding `Tensor` `[batch_size, embed_dim]` produced by
      averaging embeddings.
  
    Raises:
      ValueError: If `embed_dim` or `vocab_size` are not specified.
    """
    if not vocab_size or not embed_dim:
      raise ValueError('Must specify vocab size and embedding dimension')
    with variable_scope.variable_scope(
        scope, 'bow_encoder', [ids], reuse=reuse):
      embeddings = variables.model_variable(
          'embeddings', shape=[vocab_size, embed_dim],
          initializer=initializer, regularizer=regularizer,
          trainable=trainable)
      if sparse_lookup:
        if isinstance(ids, sparse_tensor.SparseTensor):
          sparse_ids = ids
        else:
          sparse_ids = sparse_ops.dense_to_sparse_tensor(ids)
        return contrib_embedding_ops.safe_embedding_lookup_sparse(
            [embeddings], sparse_ids, combiner='mean', default_id=0)
      else:
        if isinstance(ids, sparse_tensor.SparseTensor):
          raise TypeError('ids are expected to be dense Tensor, got: %s', ids)
        return math_ops.reduce_mean(
            embedding_ops.embedding_lookup(embeddings, ids), axis=1)
function_tokens: def bow_encoder ( ids , vocab_size , embed_dim , sparse_lookup = True , initializer = None , regularizer = None , trainable = True , scope = None , reuse = None ) : if not vocab_size or not embed_dim : raise ValueError ( 'Must specify vocab size and embedding dimension' ) with variable_scope . variable_scope ( scope , 'bow_encoder' , [ ids ] , reuse = reuse ) : embeddings = variables . model_variable ( 'embeddings' , shape = [ vocab_size , embed_dim ] , initializer = initializer , regularizer = regularizer , trainable = trainable ) if sparse_lookup : if isinstance ( ids , sparse_tensor . SparseTensor ) : sparse_ids = ids else : sparse_ids = sparse_ops . dense_to_sparse_tensor ( ids ) return contrib_embedding_ops . safe_embedding_lookup_sparse ( [ embeddings ] , sparse_ids , combiner = 'mean' , default_id = 0 ) else : if isinstance ( ids , sparse_tensor . SparseTensor ) : raise TypeError ( 'ids are expected to be dense Tensor, got: %s' , ids ) return math_ops . reduce_mean ( embedding_ops . embedding_lookup ( embeddings , ids ) , axis = 1 )