class_docstr: Base class inherited by all memory network classes.
  
  Args:
      raw_memory_dim (int): Dimension size of raw memory entries
          (before embedding). For example,
          if a raw memory entry is a word, this is the **vocabulary size**
          (imagine a one-hot representation of word). If a raw memory entry
          is a dense vector, this is the dimension size of the vector.
      input_embed_fn (optional): A callable that embeds raw memory entries
          as inputs.
          This corresponds to the `A` embedding operation in
          (Sukhbaatar et al.)
          If not provided, a default embedding operation is created as
          specified in :attr:`hparams`. See
          :meth:`~texar.tf.modules.MemNetBase.get_default_embed_fn`
          for details.
      output_embed_fn (optional): A callable that embeds raw memory entries
          as outputs.
          This corresponds to the `C` embedding operation in
          (Sukhbaatar et al.)
          If not provided, a default embedding operation is created as
          specified in :attr:`hparams`. See
          :meth:`~texar.tf.modules.MemNetBase.get_default_embed_fn`
          for details.
      query_embed_fn (optional): A callable that embeds query.
          This corresponds to the `B` embedding operation in
          (Sukhbaatar et al.). If not provided and "use_B" is True
          in :attr:`hparams`, a default embedding operation is created as
          specified in :attr:`hparams`. See
          :meth:`~texar.tf.modules.MemNetBase.get_default_embed_fn`
          for details.
          Notice: If you'd like to customize this callable, please follow
          the same number and style of dimensions as in `input_embed_fn` or
          `output_embed_fn`, and assume that the 2nd dimension of its
          input and output (which corresponds to `memory_size`) is 1.
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture and
          default values.
docstr: Creates a default embedding function. Can be used for A, C, or B
  operation.
  
  For B operation (i.e., query_embed_fn), :attr:`memory_size` must be 1.
  
  The function is a combination of both memory embedding and temporal
  embedding, with the combination method specified by "combine_mode" in
  the `embed_fn_hparams`.
  
  .. role:: python(code)
     :language: python
  
  Args:
      embed_fn_hparams (dict or HParams): Hyperparameter of the
          embedding function. See
          :func:`~texar.tf.modules.default_memnet_embed_fn` for details.
  
  Returns:
      A tuple `(embed_fn, memory_dim)`, where
  
      - **`memory_dim`** is the dimension of memory entry embedding,             inferred from :attr:`embed_fn_hparams`.
  
          - If `combine_mode` == 'add', `memory_dim` is the                 embedder dimension.
          - If `combine_mode` == 'concat', `memory_dim` is the sum                 of the memory embedder dimension and the temporal embedder                 dimension.
  
      - **`embed_fn`** is an embedding function that takes in memory             and returns memory embedding.             Specifically, the function has signature             :python:`memory_embedding= embed_fn(memory=None, soft_memory=None)`            where one of `memory` and `soft_memory` is provided (but not both).
  
      Args:
          memory: An `int` Tensor of shape
              `[batch_size, memory_size]`
              containing memory indexes used for embedding lookup.
          soft_memory: A Tensor of shape
              `[batch_size, memory_size, raw_memory_dim]`
              containing soft weights used to mix the embedding vectors.
  
      Returns:
          A Tensor of shape `[batch_size, memory_size, memory_dim]`
          containing the memory entry embeddings.
docstr_tok: ["Creates","a","default","embedding","function",".","Can","be","used","for","A",",","C",",","or","B","operation",".","For","B","operation","(","i.e.",",","query_embed_fn",")",",",":","attr",":","`","memory_size","`","must","be","1",".","The","function","is","a","combination","of","both","memory","embedding","and","temporal","embedding",",","with","the","combination","method","specified","by","``","combine_mode","''","in","the","`","embed_fn_hparams","`",".","..","role",":",":","python","(","code",")",":","language",":","python","Args",":","embed_fn_hparams","(","dict","or","HParams",")",":","Hyperparameter","of","the","embedding","function",".","See",":","func",":","`","~texar.tf.modules.default_memnet_embed_fn","`","for","details",".","Returns",":","A","tuple","`","(","embed_fn",",","memory_dim",")","`",",","where","-","*","*","`","memory_dim","`","*","*","is","the","dimension","of","memory","entry","embedding",",","inferred","from",":","attr",":","`","embed_fn_hparams","`",".","-","If","`","combine_mode","`","==","'add","'",",","`","memory_dim","`","is","the","embedder","dimension",".","-","If","`","combine_mode","`","==","'concat","'",",","`","memory_dim","`","is","the","sum","of","the","memory","embedder","dimension","and","the","temporal","embedder","dimension",".","-","*","*","`","embed_fn","`","*","*","is","an","embedding","function","that","takes","in","memory","and","returns","memory","embedding",".","Specifically",",","the","function","has","signature",":","python",":","`","memory_embedding=","embed_fn","(","memory=None",",","soft_memory=None",")","`","where","one","of","`","memory","`","and","`","soft_memory","`","is","provided","(","but","not","both",")",".","Args",":","memory",":","An","`","int","`","Tensor","of","shape","`","[","batch_size",",","memory_size","]","`","containing","memory","indexes","used","for","embedding","lookup",".","soft_memory",":","A","Tensor","of","shape","`","[","batch_size",",","memory_size",",","raw_memory_dim","]","`","containing","soft","weights","used","to","mix","the","embedding","vectors",".","Returns",":","A","Tensor","of","shape","`","[","batch_size",",","memory_size",",","memory_dim","]","`","containing","the","memory","entry","embeddings","."]
code: def get_default_embed_fn(self, memory_size, embed_fn_hparams):
      """Creates a default embedding function. Can be used for A, C, or B
          operation.
  
          For B operation (i.e., query_embed_fn), :attr:`memory_size` must be 1.
  
          The function is a combination of both memory embedding and temporal
          embedding, with the combination method specified by "combine_mode" in
          the `embed_fn_hparams`.
  
          .. role:: python(code)
             :language: python
  
          Args:
              embed_fn_hparams (dict or HParams): Hyperparameter of the
                  embedding function. See
                  :func:`~texar.tf.modules.default_memnet_embed_fn` for details.
  
          Returns:
              A tuple `(embed_fn, memory_dim)`, where
  
              - **`memory_dim`** is the dimension of memory entry embedding, \
              inferred from :attr:`embed_fn_hparams`.
  
                  - If `combine_mode` == 'add', `memory_dim` is the \
                  embedder dimension.
                  - If `combine_mode` == 'concat', `memory_dim` is the sum \
                  of the memory embedder dimension and the temporal embedder \
                  dimension.
  
              - **`embed_fn`** is an embedding function that takes in memory \
              and returns memory embedding. \
              Specifically, the function has signature \
              :python:`memory_embedding= embed_fn(memory=None, soft_memory=None)`\
              where one of `memory` and `soft_memory` is provided (but not both).
  
              Args:
                  memory: An `int` Tensor of shape
                      `[batch_size, memory_size]`
                      containing memory indexes used for embedding lookup.
                  soft_memory: A Tensor of shape
                      `[batch_size, memory_size, raw_memory_dim]`
                      containing soft weights used to mix the embedding vectors.
  
              Returns:
                  A Tensor of shape `[batch_size, memory_size, memory_dim]`
                  containing the memory entry embeddings.
  
          """
      # memory embedder
      embedder = WordEmbedder(
          vocab_size=self._raw_memory_dim,
          hparams=embed_fn_hparams["embedding"],
      )
      # temporal embedder
      temporal_embedder = PositionEmbedder(
          position_size=memory_size,
          hparams=embed_fn_hparams["temporal_embedding"],
      )
  
      combine = embed_fn_hparams["combine_mode"]
      if combine == "add":
          if embedder.dim != temporal_embedder.dim:
              raise ValueError(
                  "`embedding` and `temporal_embedding` must "
                  'have the same dimension for "add" '
                  "combination."
              )
          memory_dim = embedder.dim
      elif combine == "concat":
          memory_dim = embedder.dim + temporal_embedder.dim
  
      def _embed_fn(memory, soft_memory, mode=None):
          if memory is None and soft_memory is None:
              raise ValueError(
                  "Either `memory` or `soft_memory` is required."
              )
          if memory is not None and soft_memory is not None:
              raise ValueError(
                  "Must not specify `memory` and `soft_memory` at the "
                  "same time."
              )
  
          embedded_memory = embedder(
              ids=memory, soft_ids=soft_memory, mode=mode
          )
          temporal_embedded = temporal_embedder(
              sequence_length=tf.constant([memory_size]), mode=mode
          )
          temporal_embedded = tf.tile(
              temporal_embedded, [tf.shape(embedded_memory)[0], 1, 1]
          )
  
          if combine == "add":
              return tf.add(embedded_memory, temporal_embedded)
          elif combine == "concat":
              return tf.concat(
                  [embedded_memory, temporal_embedded], axis=-1
              )
          else:
              raise ValueError(
                  "Unknown combine method: {}".format(combine)
              )
  
      return _embed_fn, memory_dim
  
imports: import tensorflow
  from texar.tf.module_base import ModuleBase
  from texar.tf.modules.embedders import WordEmbedder, PositionEmbedder
  from texar.tf.utils.mode import switch_dropout
  from texar.tf.modules.memory.embed_fns import default_memnet_embed_fn_hparams
label_desc: Use image node_id 3 for calling the MemNetBase obj's underlying member method code with example usage: obj.get_default_embed_fn(memory_size, embed_fn_hparams) and returns: _embed_fn,  memory_dim, tf, tf