class_docstr: The model builds upon the GPT2 architecture to perform autoregressive prediction of actions in an offline RL
  setting. Refer to the paper for more details: https://arxiv.org/abs/2106.01345
class_docstr_tok: ["The","model","builds","upon","the","GPT2","architecture","to","perform","autoregressive","prediction","of","actions","in","an","offline","RL","setting",".","Refer","to","the","paper","for","more","details",":","https",":","\/\/arxiv.org\/abs\/2106.01345"]
code: def __init__(self, config):
      super().__init__(config)
      self.config = config
      self.hidden_size = config.hidden_size
      # 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.encoder = DecisionTransformerGPT2Model(config)
  
      self.embed_timestep = nn.Embedding(
          config.max_ep_len, config.hidden_size
      )
      self.embed_return = torch.nn.Linear(1, config.hidden_size)
      self.embed_state = torch.nn.Linear(
          config.state_dim, config.hidden_size
      )
      self.embed_action = torch.nn.Linear(
          config.act_dim, config.hidden_size
      )
  
      self.embed_ln = nn.LayerNorm(config.hidden_size)
  
      # note: we don't predict states or returns for the paper
      self.predict_state = torch.nn.Linear(
          config.hidden_size, config.state_dim
      )
      self.predict_action = nn.Sequential(
          *(
              [nn.Linear(config.hidden_size, config.act_dim)]
              + ([nn.Tanh()] if config.action_tanh else [])
          )
      )
      self.predict_return = torch.nn.Linear(config.hidden_size, 1)
  
      # Initialize weights and apply final processing
      self.post_init()
  
imports: import math
  import os
  from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.cuda.amp import autocast
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import Conv1D, find_pruneable_heads_and_indices, prune_conv1d_layer
  from ...utils import ModelOutput, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_decision_transformer import DecisionTransformerConfig
label_desc: Use image node_id 1 to create a new DecisionTransformerModel object from inherited base classes: DecisionTransformerPreTrainedModel with example: obj = DecisionTransformerModel(config)