code: def manual_embedding_bag(
      indices, params, weights=None, combiner="mean"
  ):
      gathered = tf.gather(params, indices)
      if weights is not None:
          gathered *= tf.expand_dims(weights, -1)
      if combiner == "sum":
          return tf.reduce_sum(gathered, -2, keepdims=False)
      else:
          assert combiner == "mean"
          assert weights is None
          return tf.reduce_mean(gathered, -2, keepdims=False)
  
file_path: addons/tensorflow_addons/layers/tests/embedding_bag_test.py
imports: import pytest
  import numpy
  import tensorflow
  from tensorflow_addons.layers.embedding_bag import EmbeddingBag, _embedding_bag
  from tensorflow_addons.utils import test_utils
label_desc: Use image node_id 1 for calling a global function with example usage: manual_embedding_bag(indices, params, weights, combiner) and returns: tf, tf