class_docstr: RNN encoder using nn.LSTM for cuDNN support / ONNX exportability.
class_docstr_tok: ["RNN","encoder","using","nn.LSTM","for","cuDNN","support","\/","ONNX","exportability","."]
code: def tile_encoder_out(
      self, beam_size: int, encoder_out: Dict[str, torch.Tensor]
  ) -> Dict[str, torch.Tensor]:
      tiled_encoder_out = encoder_out["unpacked_output"].expand(
          -1, beam_size, -1
      )
      hiddens = encoder_out["final_hiddens"]
      tiled_hiddens: List[torch.Tensor] = []
      for i in range(self.num_layers):
          tiled_hiddens.append(hiddens[i].expand(beam_size, -1))
      cells = encoder_out["final_cells"]
      tiled_cells: List[torch.Tensor] = []
      for i in range(self.num_layers):
          tiled_cells.append(cells[i].expand(beam_size, -1))
      # tiled_src_lengths = encoder_out["src_lengths"].expand(-1, beam_size, -1)
      return {
          "unpacked_output": tiled_encoder_out,
          "final_hiddens": torch.stack(tiled_hiddens, dim=0),
          "final_cells": torch.stack(tiled_cells, dim=0),
          "src_lengths": encoder_out["src_lengths"],
          "src_tokens": encoder_out["src_tokens"],
      }
  
file_path: pytext/pytext/models/seq_models/rnn_encoder.py
imports: from typing import Dict, List, Tuple
  import torch
  import torch.nn.functional
  from pytext.config import ConfigBase
  from pytext.utils.usage import log_class_usage
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  from .base import PyTextSeq2SeqModule
label_desc: Use image node_id 5 for calling the LSTMSequenceEncoder obj's underlying member method code with example usage: obj.tile_encoder_out(beam_size, encoder_out) and returns: dict