code: def __init__(
      self,
      state_dim,
      act_dim,
      hidden_size,
      max_seq_len=1024,
      max_ep_len=4096,
      action_tanh=True,
      **kwargs,
  ):
      super().__init__()
      self.state_dim = state_dim
      self.act_dim = act_dim
      self.max_seq_len = max_seq_len
      self.hidden_size = hidden_size
      self.max_length = kwargs["max_length"]
  
      config = transformers.GPT2Config(
          vocab_size=1,  # doesn't matter -- we don't use the vocab
          n_embd=hidden_size,
          **kwargs,
      )
  
      # note: the only difference between this GPT2Model and the default Huggingface version
      # is that the positional embeddings are removed (since we'll add those ourselves)
      self.transformer = GPT2Model(config)
  
      self.embed_timestep = nn.Embedding(max_ep_len, hidden_size)
      self.embed_return = torch.nn.Linear(1, hidden_size)
      self.embed_state = torch.nn.Linear(self.state_dim, hidden_size)
      self.embed_action = torch.nn.Linear(self.act_dim, hidden_size)
  
      self.embed_ln = nn.LayerNorm(hidden_size)
  
      # note: we don't predict states or returns for the paper
      self.predict_state = torch.nn.Linear(hidden_size, self.state_dim)
      self.predict_action = nn.Sequential(
          *(
              [nn.Linear(hidden_size, self.act_dim)]
              + ([nn.Tanh()] if action_tanh else [])
          )
      )
      self.predict_return = torch.nn.Linear(hidden_size, 1)
  
file_path: PARL/benchmark/torch/DT/model.py
imports: import numpy
  import torch
  import torch.nn
  import transformers
  from trajectory_gpt2 import GPT2Model
  import parl
label_desc: Use image node_id 1 to create a new TrajectoryModel object from inherited base classes: parl with example: obj = TrajectoryModel(state_dim, act_dim, hidden_size, max_seq_len, max_ep_len, action_tanh)