docstr: Returns lagged subsequences of a given sequence.
  Parameters
  ----------
  sequence : Tensor
      the sequence from which lagged subsequences should be extracted.
      Shape: (N, T, C).
  sequence_length : int
      length of sequence in the T (time) dimension (axis = 1).
  indices : List[int]
      list of lag indices to be used.
  subsequences_length : int
      length of the subsequences to be extracted.
  Returns
  --------
  lagged : Tensor
      a tensor of shape (N, S, C, I), where S = subsequences_length and
      I = len(indices), containing lagged subsequences. Specifically,
      lagged[i, j, :, k] = sequence[i, -indices[k]-S+j, :].
docstr_tok: ["Returns","lagged","subsequences","of","a","given","sequence",".","Parameters","--","--","--","--","--","sequence",":","Tensor","the","sequence","from","which","lagged","subsequences","should","be","extracted",".","Shape",":","(","N",",","T",",","C",")",".","sequence_length",":","int","length","of","sequence","in","the","T","(","time",")","dimension","(","axis","=","1",")",".","indices",":","List","[","int","]","list","of","lag","indices","to","be","used",".","subsequences_length",":","int","length","of","the","subsequences","to","be","extracted",".","Returns","--","--","--","--","lagged",":","Tensor","a","tensor","of","shape","(","N",",","S",",","C",",","I",")",",","where","S","=","subsequences_length","and","I","=","len","(","indices",")",",","containing","lagged","subsequences",".","Specifically",",","lagged","[","i",",","j",",",":",",","k","]","=","sequence","[","i",",","-indices","[","k","]","-S+j",",",":","]","."]
code: def get_lagged_subsequences(
      sequence: torch.Tensor,
      sequence_length: int,
      indices: List[int],
      subsequences_length: int = 1,
  ) -> torch.Tensor:
      """
      Returns lagged subsequences of a given sequence.
      Parameters
      ----------
      sequence : Tensor
          the sequence from which lagged subsequences should be extracted.
          Shape: (N, T, C).
      sequence_length : int
          length of sequence in the T (time) dimension (axis = 1).
      indices : List[int]
          list of lag indices to be used.
      subsequences_length : int
          length of the subsequences to be extracted.
      Returns
      --------
      lagged : Tensor
          a tensor of shape (N, S, C, I), where S = subsequences_length and
          I = len(indices), containing lagged subsequences. Specifically,
          lagged[i, j, :, k] = sequence[i, -indices[k]-S+j, :].
      """
      assert max(indices) + subsequences_length <= sequence_length, (
          f"lags cannot go further than history length, found lag {max(indices)} "
          f"while history length is only {sequence_length}"
      )
      assert all(lag_index >= 0 for lag_index in indices)
  
      lagged_values = []
      for lag_index in indices:
          begin_index = -lag_index - subsequences_length
          end_index = -lag_index if lag_index > 0 else None
          lagged_values.append(sequence[:, begin_index:end_index, ...])
      return torch.stack(lagged_values, dim=-1)
  
imports: from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from torch.distributions import Distribution
  from gluonts.core.component import validated
  from gluonts.torch.modules.distribution_output import DistributionOutput
  from pts.model import weighted_average
  from pts.modules import MeanScaler, NOPScaler, FeatureEmbedder
label_desc: Use image node_id 2 for calling the DeepARNetwork obj's underlying member method code with example usage: obj.get_lagged_subsequences(sequence, sequence_length, indices, subsequences_length) and returns: torch