docstr: Encode sequence into hidden state
docstr_tok: ["Encode","sequence","into","hidden","state"]
code: def encode(self, x: Dict[str, torch.Tensor]) -> HiddenState:
      """
      Encode sequence into hidden state
      """
      # encode using rnn
      assert x["encoder_lengths"].min() > 0
      encoder_lengths = x["encoder_lengths"] - 1
      input_vector = self.construct_input_vector(
          x["encoder_cat"], x["encoder_cont"]
      )
      _, hidden_state = self.rnn(
          input_vector, lengths=encoder_lengths, enforce_sorted=False
      )  # second ouput is not needed (hidden state)
      return hidden_state
  
file_path: pytorch-forecasting/pytorch_forecasting/models/rnn/__init__.py
imports: from copy import copy
  from typing import Dict, List, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from pytorch_forecasting.data.encoders import MultiNormalizer, NaNLabelEncoder
  from pytorch_forecasting.data.timeseries import TimeSeriesDataSet
  from pytorch_forecasting.metrics import MAE, MAPE, MASE, RMSE, SMAPE, MultiHorizonMetric, MultiLoss, QuantileLoss
  from pytorch_forecasting.models.base_model import AutoRegressiveBaseModelWithCovariates
  from pytorch_forecasting.models.nn import HiddenState, MultiEmbedding, get_rnn
  from pytorch_forecasting.utils import apply_to_list, to_list
label_desc: Use image node_id 4 for calling the RecurrentNetwork obj's underlying member method code with example usage: obj.encode(x) and returns: hidden_state