EmbeddingBag
class torch.nn.EmbeddingBag(num_embeddings, embedding_dim, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='mean', sparse=False, _weight=None, include_last_offset=False, padding_idx=None, device=None, dtype=None)
Computes sums or means of 'bags' of embeddings, without
   instantiating the intermediate embeddings.
For bags of constant length, no "per_sample_weights", no indices
   equal to "padding_idx", and with 2D inputs, this class
  * with "mode="sum"" is equivalent to "Embedding" followed by
    "torch.sum(dim=1)",

  * with "mode="mean"" is equivalent to "Embedding" followed by
    "torch.mean(dim=1)",

  * with "mode="max"" is equivalent to "Embedding" followed by
    "torch.max(dim=1)".

However, "EmbeddingBag" is much more time and memory efficient than
   using a chain of these operations.
EmbeddingBag also supports per-sample weights as an argument to the
   forward pass. This scales the output of the Embedding before