class_docstr: A model built on the DeepSet architecture.
docstr: Computes the model output by mapping all inputs independently into the
  latent space and averaging contiguous blocks of latent representations
  as specified by the lengths.
  
  Then passes the averaged latent representations along with the number
  of members that have been averaged to the decoder.
docstr_tok: ["Computes","the","model","output","by","mapping","all","inputs","independently","into","the","latent","space","and","averaging","contiguous","blocks","of","latent","representations","as","specified","by","the","lengths",".","Then","passes","the","averaged","latent","representations","along","with","the","number","of","members","that","have","been","averaged","to","the","decoder","."]
code: def forward(
      self, x: torch.Tensor, lengths: torch.Tensor
  ) -> torch.Tensor:
      """
      Computes the model output by mapping all inputs independently into the
      latent space and averaging contiguous blocks of latent representations
      as specified by the lengths.
  
      Then passes the averaged latent representations along with the number
      of members that have been averaged to the decoder.
      """
      # Run encoder
      z = self.encoder(x)
  
      # Sum encodings of different length together
      indices = torch.zeros(
          z.size(0), dtype=torch.long, device=z.device
      )
      indices[lengths.cumsum(0)[:-1]] = 1
      groups = indices.cumsum(0)
  
      encodings = torch.zeros(
          lengths.size(0), z.size(1), dtype=z.dtype, device=z.device
      )
      encodings.index_add_(0, groups, z)
  
      # Run decoder
      return self.decoder(
          torch.cat(
              [encodings / lengths, lengths.float().unsqueeze(1)], dim=1
          )
      )
  
file_path: gluonts/src/gluonts/nursery/tsbench/src/tsbench/surrogate/torch/deepset.py
imports: from typing import List
  import torch
  from torch import nn
label_desc: Use image node_id 2 for calling the DeepSetModel obj's underlying member method code with example usage: obj.forward(x, lengths) and returns: self