import{s as zt,o as Et,n as lt}from"../chunks/scheduler.9bc65507.js";import{S as Wt,i as Bt,g as o,s as c,u as _,A as Ft,h as r,f as t,c as d,j as h,v as T,y as u,k as m,o as a,a as i,w as v,d as M,t as y,x as b}from"../chunks/index.78c82d43.js";import{T as It}from"../chunks/Tip.87d55b76.js";import{D as $e}from"../chunks/Docstring.4e7352e2.js";import{C as Gt}from"../chunks/CodeBlock.73e038be.js";import{I as Ce}from"../chunks/IconCopyLink.bedaa44d.js";import{E as Nt}from"../chunks/ExampleCodeBlock.872b014d.js";function At(R){let l,w="Example:",f,p,g;return p=new Gt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlY2lzaW9uVHJhbnNmb3JtZXJDb25maWclMkMlMjBEZWNpc2lvblRyYW5zZm9ybWVyTW9kZWwlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwRGVjaXNpb25UcmFuc2Zvcm1lciUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwRGVjaXNpb25UcmFuc2Zvcm1lckNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBEZWNpc2lvblRyYW5zZm9ybWVyTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DecisionTransformerConfig, DecisionTransformerModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a DecisionTransformer configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = DecisionTransformerConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DecisionTransformerModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){l=o("p"),l.textContent=w,f=c(),_(p.$$.fragment)},l(s){l=r(s,"P",{"data-svelte-h":!0}),u(l)!=="svelte-11lpom8"&&(l.textContent=w),f=d(s),T(p.$$.fragment,s)},m(s,j){i(s,l,j),i(s,f,j),v(p,s,j),g=!0},p:lt,i(s){g||(M(p.$$.fragment,s),g=!0)},o(s){y(p.$$.fragment,s),g=!1},d(s){s&&(t(l),t(f)),b(p,s)}}}function Ht(R){let l,w=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){l=o("p"),l.innerHTML=w},l(f){l=r(f,"P",{"data-svelte-h":!0}),u(l)!=="svelte-fincs2"&&(l.innerHTML=w)},m(f,p){i(f,l,p)},p:lt,d(f){f&&t(l)}}}function St(R){let l,w="Examples:",f,p,g;return p=new Gt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlY2lzaW9uVHJhbnNmb3JtZXJNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBbW9kZWwlMjAlM0QlMjBEZWNpc2lvblRyYW5zZm9ybWVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmVkYmVlY2hpbmclMkZkZWNpc2lvbi10cmFuc2Zvcm1lci1neW0taG9wcGVyLW1lZGl1bSUyMiklMEElMjMlMjBldmFsdWF0aW9uJTBBbW9kZWwlMjAlM0QlMjBtb2RlbC50byhkZXZpY2UpJTBBbW9kZWwuZXZhbCgpJTBBJTBBZW52JTIwJTNEJTIwZ3ltLm1ha2UoJTIySG9wcGVyLXYzJTIyKSUwQXN0YXRlX2RpbSUyMCUzRCUyMGVudi5vYnNlcnZhdGlvbl9zcGFjZS5zaGFwZSU1QjAlNUQlMEFhY3RfZGltJTIwJTNEJTIwZW52LmFjdGlvbl9zcGFjZS5zaGFwZSU1QjAlNUQlMEElMEFzdGF0ZSUyMCUzRCUyMGVudi5yZXNldCgpJTBBc3RhdGVzJTIwJTNEJTIwdG9yY2guZnJvbV9udW1weShzdGF0ZSkucmVzaGFwZSgxJTJDJTIwMSUyQyUyMHN0YXRlX2RpbSkudG8oZGV2aWNlJTNEZGV2aWNlJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdDMyKSUwQWFjdGlvbnMlMjAlM0QlMjB0b3JjaC56ZXJvcygoMSUyQyUyMDElMkMlMjBhY3RfZGltKSUyQyUyMGRldmljZSUzRGRldmljZSUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQzMiklMEFyZXdhcmRzJTIwJTNEJTIwdG9yY2guemVyb3MoMSUyQyUyMDElMkMlMjBkZXZpY2UlM0RkZXZpY2UlMkMlMjBkdHlwZSUzRHRvcmNoLmZsb2F0MzIpJTBBdGFyZ2V0X3JldHVybiUyMCUzRCUyMHRvcmNoLnRlbnNvcihUQVJHRVRfUkVUVVJOJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdDMyKS5yZXNoYXBlKDElMkMlMjAxKSUwQXRpbWVzdGVwcyUyMCUzRCUyMHRvcmNoLnRlbnNvcigwJTJDJTIwZGV2aWNlJTNEZGV2aWNlJTJDJTIwZHR5cGUlM0R0b3JjaC5sb25nKS5yZXNoYXBlKDElMkMlMjAxKSUwQWF0dGVudGlvbl9tYXNrJTIwJTNEJTIwdG9yY2guemVyb3MoMSUyQyUyMDElMkMlMjBkZXZpY2UlM0RkZXZpY2UlMkMlMjBkdHlwZSUzRHRvcmNoLmZsb2F0MzIpJTBBJTBBJTIzJTIwZm9yd2FyZCUyMHBhc3MlMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwc3RhdGVfcHJlZHMlMkMlMjBhY3Rpb25fcHJlZHMlMkMlMjByZXR1cm5fcHJlZHMlMjAlM0QlMjBtb2RlbCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzdGF0ZXMlM0RzdGF0ZXMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhY3Rpb25zJTNEYWN0aW9ucyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJld2FyZHMlM0RyZXdhcmRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuc190b19nbyUzRHRhcmdldF9yZXR1cm4lMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0aW1lc3RlcHMlM0R0aW1lc3RlcHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhdHRlbnRpb25fbWFzayUzRGF0dGVudGlvbl9tYXNrJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuX2RpY3QlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DecisionTransformerModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>model = DecisionTransformerModel.from_pretrained(<span class="hljs-string">&quot;edbeeching/decision-transformer-gym-hopper-medium&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># evaluation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = model.to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">eval</span>()

<span class="hljs-meta">&gt;&gt;&gt; </span>env = gym.make(<span class="hljs-string">&quot;Hopper-v3&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>state_dim = env.observation_space.shape[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>act_dim = env.action_space.shape[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>state = env.reset()
<span class="hljs-meta">&gt;&gt;&gt; </span>states = torch.from_numpy(state).reshape(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, state_dim).to(device=device, dtype=torch.float32)
<span class="hljs-meta">&gt;&gt;&gt; </span>actions = torch.zeros((<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, act_dim), device=device, dtype=torch.float32)
<span class="hljs-meta">&gt;&gt;&gt; </span>rewards = torch.zeros(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, device=device, dtype=torch.float32)
<span class="hljs-meta">&gt;&gt;&gt; </span>target_return = torch.tensor(TARGET_RETURN, dtype=torch.float32).reshape(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>timesteps = torch.tensor(<span class="hljs-number">0</span>, device=device, dtype=torch.long).reshape(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>attention_mask = torch.zeros(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, device=device, dtype=torch.float32)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    state_preds, action_preds, return_preds = model(
<span class="hljs-meta">... </span>        states=states,
<span class="hljs-meta">... </span>        actions=actions,
<span class="hljs-meta">... </span>        rewards=rewards,
<span class="hljs-meta">... </span>        returns_to_go=target_return,
<span class="hljs-meta">... </span>        timesteps=timesteps,
<span class="hljs-meta">... </span>        attention_mask=attention_mask,
<span class="hljs-meta">... </span>        return_dict=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    )`,wrap:!1}}),{c(){l=o("p"),l.textContent=w,f=c(),_(p.$$.fragment)},l(s){l=r(s,"P",{"data-svelte-h":!0}),u(l)!=="svelte-kvfsh7"&&(l.textContent=w),f=d(s),T(p.$$.fragment,s)},m(s,j){i(s,l,j),i(s,f,j),v(p,s,j),g=!0},p:lt,i(s){g||(M(p.$$.fragment,s),g=!0)},o(s){y(p.$$.fragment,s),g=!1},d(s){s&&(t(l),t(f)),b(p,s)}}}function Pt(R){let l,w,f,p,g,s,j,S,Ve,ie,ct="Decision Transformer",Je,x,N,Te,P,Xe,le,dt="Overview",xe,L,mt=`The Decision Transformer model was proposed in <a href="https://arxiv.org/abs/2106.01345" rel="nofollow">Decision Transformer: Reinforcement Learning via Sequence Modeling</a><br/>
by Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, Igor Mordatch.`,De,V,pt="The abstract from the paper is the following:",ke,X,ht=`<em>We introduce a framework that abstracts Reinforcement Learning (RL) as a sequence modeling problem.
This allows us to draw upon the simplicity and scalability of the Transformer architecture, and associated advances
in language modeling such as GPT-x and BERT. In particular, we present Decision Transformer, an architecture that
casts the problem of RL as conditional sequence modeling. Unlike prior approaches to RL that fit value functions or
compute policy gradients, Decision Transformer simply outputs the optimal actions by leveraging a causally masked
Transformer. By conditioning an autoregressive model on the desired return (reward), past states, and actions, our
Decision Transformer model can generate future actions that achieve the desired return. Despite its simplicity,
Decision Transformer matches or exceeds the performance of state-of-the-art model-free offline RL baselines on
Atari, OpenAI Gym, and Key-to-Door tasks.</em>`,Ze,Y,ft="Tips:",Ue,q,gt="This version of the model is for tasks where the state is a vector, image-based states will come soon.",Re,O,ut='This model was contributed by <a href="https://huggingface.co/edbeeching" rel="nofollow">edbeeching</a>. The original code can be found <a href="https://github.com/kzl/decision-transformer" rel="nofollow">here</a>.',Ne,D,G,ve,Q,Ye,ce,_t="DecisionTransformerConfig",Ge,$,K,qe,de,Tt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.34.0/en/model_doc/decision_transformer#transformers.DecisionTransformerModel">DecisionTransformerModel</a>. It is used to
instantiate a Decision Transformer model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the standard
DecisionTransformer architecture. Many of the config options are used to instatiate the GPT2 model that is used as
part of the architecture.`,Oe,me,vt=`Configuration objects inherit from <a href="/docs/transformers/v4.34.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/v4.34.0/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,Qe,z,ze,k,E,Me,ee,Ke,pe,Mt="DecisionTransformerGPT2Model",Ee,Z,te,et,he,ne,We,U,W,ye,oe,tt,fe,yt="DecisionTransformerModel",Be,C,re,nt,ge,bt=`The Decision Transformer Model
This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,ot,ue,wt=`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: <a href="https://arxiv.org/abs/2106.01345" rel="nofollow">https://arxiv.org/abs/2106.01345</a>`,rt,J,se,st,_e,jt='The <a href="/docs/transformers/v4.34.0/en/model_doc/decision_transformer#transformers.DecisionTransformerModel">DecisionTransformerModel</a> forward method, overrides the <code>__call__</code> special method.',at,B,it,F,Fe,be,Ie;return S=new Ce({}),P=new Ce({}),Q=new Ce({}),K=new $e({props:{name:"class transformers.DecisionTransformerConfig",anchor:"transformers.DecisionTransformerConfig",parameters:[{name:"state_dim",val:" = 17"},{name:"act_dim",val:" = 4"},{name:"hidden_size",val:" = 128"},{name:"max_ep_len",val:" = 4096"},{name:"action_tanh",val:" = True"},{name:"vocab_size",val:" = 1"},{name:"n_positions",val:" = 1024"},{name:"n_layer",val:" = 3"},{name:"n_head",val:" = 1"},{name:"n_inner",val:" = None"},{name:"activation_function",val:" = 'relu'"},{name:"resid_pdrop",val:" = 0.1"},{name:"embd_pdrop",val:" = 0.1"},{name:"attn_pdrop",val:" = 0.1"},{name:"layer_norm_epsilon",val:" = 1e-05"},{name:"initializer_range",val:" = 0.02"},{name:"scale_attn_weights",val:" = True"},{name:"use_cache",val:" = True"},{name:"bos_token_id",val:" = 50256"},{name:"eos_token_id",val:" = 50256"},{name:"scale_attn_by_inverse_layer_idx",val:" = False"},{name:"reorder_and_upcast_attn",val:" = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DecisionTransformerConfig.state_dim",description:`<strong>state_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 17) &#x2014;
The state size for the RL environment`,name:"state_dim"},{anchor:"transformers.DecisionTransformerConfig.act_dim",description:`<strong>act_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The size of the output action space`,name:"act_dim"},{anchor:"transformers.DecisionTransformerConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
The size of the hidden layers`,name:"hidden_size"},{anchor:"transformers.DecisionTransformerConfig.max_ep_len",description:`<strong>max_ep_len</strong> (<code>int</code>, <em>optional</em>, defaults to 4096) &#x2014;
The maximum length of an episode in the environment`,name:"max_ep_len"},{anchor:"transformers.DecisionTransformerConfig.action_tanh",description:`<strong>action_tanh</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Whether to use a tanh activation on action prediction`,name:"action_tanh"},{anchor:"transformers.DecisionTransformerConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 50257) &#x2014;
Vocabulary size of the GPT-2 model. Defines the number of different tokens that can be represented by the
<code>inputs_ids</code> passed when calling <a href="/docs/transformers/v4.34.0/en/model_doc/decision_transformer#transformers.DecisionTransformerModel">DecisionTransformerModel</a>.`,name:"vocab_size"},{anchor:"transformers.DecisionTransformerConfig.n_positions",description:`<strong>n_positions</strong> (<code>int</code>, <em>optional</em>, defaults to 1024) &#x2014;
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 2048).`,name:"n_positions"},{anchor:"transformers.DecisionTransformerConfig.n_layer",description:`<strong>n_layer</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"n_layer"},{anchor:"transformers.DecisionTransformerConfig.n_head",description:`<strong>n_head</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"n_head"},{anchor:"transformers.DecisionTransformerConfig.n_inner",description:`<strong>n_inner</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Dimensionality of the inner feed-forward layers. If unset, will default to 4 times <code>n_embd</code>.`,name:"n_inner"},{anchor:"transformers.DecisionTransformerConfig.activation_function",description:`<strong>activation_function</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
Activation function, to be selected in the list <code>[&quot;relu&quot;, &quot;silu&quot;, &quot;gelu&quot;, &quot;tanh&quot;, &quot;gelu_new&quot;]</code>.`,name:"activation_function"},{anchor:"transformers.DecisionTransformerConfig.resid_pdrop",description:`<strong>resid_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"resid_pdrop"},{anchor:"transformers.DecisionTransformerConfig.embd_pdrop",description:`<strong>embd_pdrop</strong> (<code>int</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the embeddings.`,name:"embd_pdrop"},{anchor:"transformers.DecisionTransformerConfig.attn_pdrop",description:`<strong>attn_pdrop</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The dropout ratio for the attention.`,name:"attn_pdrop"},{anchor:"transformers.DecisionTransformerConfig.layer_norm_epsilon",description:`<strong>layer_norm_epsilon</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-5) &#x2014;
The epsilon to use in the layer normalization layers.`,name:"layer_norm_epsilon"},{anchor:"transformers.DecisionTransformerConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.DecisionTransformerConfig.scale_attn_weights",description:`<strong>scale_attn_weights</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Scale attention weights by dividing by sqrt(hidden_size)..`,name:"scale_attn_weights"},{anchor:"transformers.DecisionTransformerConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should return the last key/values attentions (not used by all models).`,name:"use_cache"},{anchor:"transformers.DecisionTransformerConfig.scale_attn_by_inverse_layer_idx",description:`<strong>scale_attn_by_inverse_layer_idx</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to additionally scale attention weights by <code>1 / layer_idx + 1</code>.`,name:"scale_attn_by_inverse_layer_idx"},{anchor:"transformers.DecisionTransformerConfig.reorder_and_upcast_attn",description:`<strong>reorder_and_upcast_attn</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to scale keys (K) prior to computing attention (dot-product) and upcast attention
dot-product/softmax to float() when training with mixed precision.`,name:"reorder_and_upcast_attn"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/decision_transformer/configuration_decision_transformer.py#L31"}}),z=new Nt({props:{anchor:"transformers.DecisionTransformerConfig.example",$$slots:{default:[At]},$$scope:{ctx:R}}}),ee=new Ce({}),te=new $e({props:{name:"class transformers.DecisionTransformerGPT2Model",anchor:"transformers.DecisionTransformerGPT2Model",parameters:[{name:"config",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/decision_transformer/modeling_decision_transformer.py#L477"}}),ne=new $e({props:{name:"forward",anchor:"transformers.DecisionTransformerGPT2Model.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"position_ids",val:": typing.Optional[torch.LongTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"inputs_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"encoder_hidden_states",val:": typing.Optional[torch.Tensor] = None"},{name:"encoder_attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"use_cache",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/decision_transformer/modeling_decision_transformer.py#L507"}}),oe=new Ce({}),re=new $e({props:{name:"class transformers.DecisionTransformerModel",anchor:"transformers.DecisionTransformerModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.DecisionTransformerModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.34.0/en/model_doc/decision_transformer#transformers.DecisionTransformerConfig">~DecisionTransformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/decision_transformer/modeling_decision_transformer.py#L796"}}),se=new $e({props:{name:"forward",anchor:"transformers.DecisionTransformerModel.forward",parameters:[{name:"states",val:": typing.Optional[torch.FloatTensor] = None"},{name:"actions",val:": typing.Optional[torch.FloatTensor] = None"},{name:"rewards",val:": typing.Optional[torch.FloatTensor] = None"},{name:"returns_to_go",val:": typing.Optional[torch.FloatTensor] = None"},{name:"timesteps",val:": typing.Optional[torch.LongTensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.DecisionTransformerModel.forward.states",description:`<strong>states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, episode_length, state_dim)</code>) &#x2014;
The states for each step in the trajectory`,name:"states"},{anchor:"transformers.DecisionTransformerModel.forward.actions",description:`<strong>actions</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, episode_length, act_dim)</code>) &#x2014;
The actions taken by the &#x201C;expert&#x201D; policy for the current state, these are masked for auto regressive
prediction`,name:"actions"},{anchor:"transformers.DecisionTransformerModel.forward.rewards",description:`<strong>rewards</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, episode_length, 1)</code>) &#x2014;
The rewards for each state, action`,name:"rewards"},{anchor:"transformers.DecisionTransformerModel.forward.returns_to_go",description:`<strong>returns_to_go</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, episode_length, 1)</code>) &#x2014;
The returns for each state in the trajectory`,name:"returns_to_go"},{anchor:"transformers.DecisionTransformerModel.forward.timesteps",description:`<strong>timesteps</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, episode_length)</code>) &#x2014;
The timestep for each step in the trajectory`,name:"timesteps"},{anchor:"transformers.DecisionTransformerModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, episode_length)</code>) &#x2014;
Masking, used to mask the actions when performing autoregressive prediction`,name:"attention_mask"}],source:"https://github.com/huggingface/transformers/blob/v4.34.0/src/transformers/models/decision_transformer/modeling_decision_transformer.py#L829",returnDescription:`
<p>A <code>transformers.models.decision_transformer.modeling_decision_transformer.DecisionTransformerOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/v4.34.0/en/model_doc/decision_transformer#transformers.DecisionTransformerConfig"
>DecisionTransformerConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>state_preds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, state_dim)</code>) — Environment state predictions</p>
</li>
<li>
<p><strong>action_preds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, action_dim)</code>) — Model action predictions</p>
</li>
<li>
<p><strong>return_preds</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, 1)</code>) — Predicted returns for each state</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings + one for the output of each layer) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><code>transformers.models.decision_transformer.modeling_decision_transformer.DecisionTransformerOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),B=new It({props:{$$slots:{default:[Ht]},$$scope:{ctx:R}}}),F=new Nt({props:{anchor:"transformers.DecisionTransformerModel.forward.example",$$slots:{default:[St]},$$scope:{ctx:R}}}),{c(){l=o("meta"),w=c(),f=o("p"),p=c(),g=o("h1"),s=o("a"),j=o("span"),_(S.$$.fragment),Ve=c(),ie=o("span"),ie.textContent=ct,Je=c(),x=o("h2"),N=o("a"),Te=o("span"),_(P.$$.fragment),Xe=c(),le=o("span"),le.textContent=dt,xe=c(),L=o("p"),L.innerHTML=mt,De=c(),V=o("p"),V.textContent=pt,ke=c(),X=o("p"),X.innerHTML=ht,Ze=c(),Y=o("p"),Y.textContent=ft,Ue=c(),q=o("p"),q.textContent=gt,Re=c(),O=o("p"),O.innerHTML=ut,Ne=c(),D=o("h2"),G=o("a"),ve=o("span"),_(Q.$$.fragment),Ye=c(),ce=o("span"),ce.textContent=_t,Ge=c(),$=o("div"),_(K.$$.fragment),qe=c(),de=o("p"),de.innerHTML=Tt,Oe=c(),me=o("p"),me.innerHTML=vt,Qe=c(),_(z.$$.fragment),ze=c(),k=o("h2"),E=o("a"),Me=o("span"),_(ee.$$.fragment),Ke=c(),pe=o("span"),pe.textContent=Mt,Ee=c(),Z=o("div"),_(te.$$.fragment),et=c(),he=o("div"),_(ne.$$.fragment),We=c(),U=o("h2"),W=o("a"),ye=o("span"),_(oe.$$.fragment),tt=c(),fe=o("span"),fe.textContent=yt,Be=c(),C=o("div"),_(re.$$.fragment),nt=c(),ge=o("p"),ge.innerHTML=bt,ot=c(),ue=o("p"),ue.innerHTML=wt,rt=c(),J=o("div"),_(se.$$.fragment),st=c(),_e=o("p"),_e.innerHTML=jt,at=c(),_(B.$$.fragment),it=c(),_(F.$$.fragment),Fe=c(),be=o("p"),this.h()},l(e){const n=Ft("svelte-1phssyn",document.head);l=r(n,"META",{name:!0,content:!0}),n.forEach(t),w=d(e),f=r(e,"P",{}),h(f).forEach(t),p=d(e),g=r(e,"H1",{class:!0});var ae=h(g);s=r(ae,"A",{id:!0,class:!0,href:!0});var we=h(s);j=r(we,"SPAN",{});var je=h(j);T(S.$$.fragment,je),je.forEach(t),we.forEach(t),Ve=d(ae),ie=r(ae,"SPAN",{"data-svelte-h":!0}),u(ie)!=="svelte-166vbr2"&&(ie.textContent=ct),ae.forEach(t),Je=d(e),x=r(e,"H2",{class:!0});var Ae=h(x);N=r(Ae,"A",{id:!0,class:!0,href:!0});var $t=h(N);Te=r($t,"SPAN",{});var Ct=h(Te);T(P.$$.fragment,Ct),Ct.forEach(t),$t.forEach(t),Xe=d(Ae),le=r(Ae,"SPAN",{"data-svelte-h":!0}),u(le)!=="svelte-1jsw1pg"&&(le.textContent=dt),Ae.forEach(t),xe=d(e),L=r(e,"P",{"data-svelte-h":!0}),u(L)!=="svelte-xt2qk"&&(L.innerHTML=mt),De=d(e),V=r(e,"P",{"data-svelte-h":!0}),u(V)!=="svelte-vfdo9a"&&(V.textContent=pt),ke=d(e),X=r(e,"P",{"data-svelte-h":!0}),u(X)!=="svelte-lyw843"&&(X.innerHTML=ht),Ze=d(e),Y=r(e,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-axv494"&&(Y.textContent=ft),Ue=d(e),q=r(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-15ofbd"&&(q.textContent=gt),Re=d(e),O=r(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-1ferxi2"&&(O.innerHTML=ut),Ne=d(e),D=r(e,"H2",{class:!0});var He=h(D);G=r(He,"A",{id:!0,class:!0,href:!0});var Jt=h(G);ve=r(Jt,"SPAN",{});var xt=h(ve);T(Q.$$.fragment,xt),xt.forEach(t),Jt.forEach(t),Ye=d(He),ce=r(He,"SPAN",{"data-svelte-h":!0}),u(ce)!=="svelte-1v1oem0"&&(ce.textContent=_t),He.forEach(t),Ge=d(e),$=r(e,"DIV",{class:!0});var I=h($);T(K.$$.fragment,I),qe=d(I),de=r(I,"P",{"data-svelte-h":!0}),u(de)!=="svelte-lrkes9"&&(de.innerHTML=Tt),Oe=d(I),me=r(I,"P",{"data-svelte-h":!0}),u(me)!=="svelte-10kqkkl"&&(me.innerHTML=vt),Qe=d(I),T(z.$$.fragment,I),I.forEach(t),ze=d(e),k=r(e,"H2",{class:!0});var Se=h(k);E=r(Se,"A",{id:!0,class:!0,href:!0});var Dt=h(E);Me=r(Dt,"SPAN",{});var kt=h(Me);T(ee.$$.fragment,kt),kt.forEach(t),Dt.forEach(t),Ke=d(Se),pe=r(Se,"SPAN",{"data-svelte-h":!0}),u(pe)!=="svelte-1o51rty"&&(pe.textContent=Mt),Se.forEach(t),Ee=d(e),Z=r(e,"DIV",{class:!0});var Pe=h(Z);T(te.$$.fragment,Pe),et=d(Pe),he=r(Pe,"DIV",{class:!0});var Zt=h(he);T(ne.$$.fragment,Zt),Zt.forEach(t),Pe.forEach(t),We=d(e),U=r(e,"H2",{class:!0});var Le=h(U);W=r(Le,"A",{id:!0,class:!0,href:!0});var Ut=h(W);ye=r(Ut,"SPAN",{});var Rt=h(ye);T(oe.$$.fragment,Rt),Rt.forEach(t),Ut.forEach(t),tt=d(Le),fe=r(Le,"SPAN",{"data-svelte-h":!0}),u(fe)!=="svelte-kk45aj"&&(fe.textContent=yt),Le.forEach(t),Be=d(e),C=r(e,"DIV",{class:!0});var A=h(C);T(re.$$.fragment,A),nt=d(A),ge=r(A,"P",{"data-svelte-h":!0}),u(ge)!=="svelte-s64yr0"&&(ge.innerHTML=bt),ot=d(A),ue=r(A,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-31643h"&&(ue.innerHTML=wt),rt=d(A),J=r(A,"DIV",{class:!0});var H=h(J);T(se.$$.fragment,H),st=d(H),_e=r(H,"P",{"data-svelte-h":!0}),u(_e)!=="svelte-1e1m41n"&&(_e.innerHTML=jt),at=d(H),T(B.$$.fragment,H),it=d(H),T(F.$$.fragment,H),H.forEach(t),A.forEach(t),Fe=d(e),be=r(e,"P",{}),h(be).forEach(t),this.h()},h(){m(l,"name","hf:doc:metadata"),m(l,"content",JSON.stringify(Lt)),m(s,"id","decision-transformer"),m(s,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(s,"href","#decision-transformer"),m(g,"class","relative group"),m(N,"id","overview"),m(N,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(N,"href","#overview"),m(x,"class","relative group"),m(G,"id","transformers.DecisionTransformerConfig"),m(G,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(G,"href","#transformers.DecisionTransformerConfig"),m(D,"class","relative group"),m($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(E,"id","transformers.DecisionTransformerGPT2Model"),m(E,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(E,"href","#transformers.DecisionTransformerGPT2Model"),m(k,"class","relative group"),m(he,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(W,"id","transformers.DecisionTransformerModel"),m(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(W,"href","#transformers.DecisionTransformerModel"),m(U,"class","relative group"),m(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,n){a(document.head,l),i(e,w,n),i(e,f,n),i(e,p,n),i(e,g,n),a(g,s),a(s,j),v(S,j,null),a(g,Ve),a(g,ie),i(e,Je,n),i(e,x,n),a(x,N),a(N,Te),v(P,Te,null),a(x,Xe),a(x,le),i(e,xe,n),i(e,L,n),i(e,De,n),i(e,V,n),i(e,ke,n),i(e,X,n),i(e,Ze,n),i(e,Y,n),i(e,Ue,n),i(e,q,n),i(e,Re,n),i(e,O,n),i(e,Ne,n),i(e,D,n),a(D,G),a(G,ve),v(Q,ve,null),a(D,Ye),a(D,ce),i(e,Ge,n),i(e,$,n),v(K,$,null),a($,qe),a($,de),a($,Oe),a($,me),a($,Qe),v(z,$,null),i(e,ze,n),i(e,k,n),a(k,E),a(E,Me),v(ee,Me,null),a(k,Ke),a(k,pe),i(e,Ee,n),i(e,Z,n),v(te,Z,null),a(Z,et),a(Z,he),v(ne,he,null),i(e,We,n),i(e,U,n),a(U,W),a(W,ye),v(oe,ye,null),a(U,tt),a(U,fe),i(e,Be,n),i(e,C,n),v(re,C,null),a(C,nt),a(C,ge),a(C,ot),a(C,ue),a(C,rt),a(C,J),v(se,J,null),a(J,st),a(J,_e),a(J,at),v(B,J,null),a(J,it),v(F,J,null),i(e,Fe,n),i(e,be,n),Ie=!0},p(e,[n]){const ae={};n&2&&(ae.$$scope={dirty:n,ctx:e}),z.$set(ae);const we={};n&2&&(we.$$scope={dirty:n,ctx:e}),B.$set(we);const je={};n&2&&(je.$$scope={dirty:n,ctx:e}),F.$set(je)},i(e){Ie||(M(S.$$.fragment,e),M(P.$$.fragment,e),M(Q.$$.fragment,e),M(K.$$.fragment,e),M(z.$$.fragment,e),M(ee.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(oe.$$.fragment,e),M(re.$$.fragment,e),M(se.$$.fragment,e),M(B.$$.fragment,e),M(F.$$.fragment,e),Ie=!0)},o(e){y(S.$$.fragment,e),y(P.$$.fragment,e),y(Q.$$.fragment,e),y(K.$$.fragment,e),y(z.$$.fragment,e),y(ee.$$.fragment,e),y(te.$$.fragment,e),y(ne.$$.fragment,e),y(oe.$$.fragment,e),y(re.$$.fragment,e),y(se.$$.fragment,e),y(B.$$.fragment,e),y(F.$$.fragment,e),Ie=!1},d(e){e&&(t(w),t(f),t(p),t(g),t(Je),t(x),t(xe),t(L),t(De),t(V),t(ke),t(X),t(Ze),t(Y),t(Ue),t(q),t(Re),t(O),t(Ne),t(D),t(Ge),t($),t(ze),t(k),t(Ee),t(Z),t(We),t(U),t(Be),t(C),t(Fe),t(be)),t(l),b(S),b(P),b(Q),b(K),b(z),b(ee),b(te),b(ne),b(oe),b(re),b(se),b(B),b(F)}}}const Lt={local:"decision-transformer",sections:[{local:"overview",title:"Overview"},{local:"transformers.DecisionTransformerConfig",title:"DecisionTransformerConfig"},{local:"transformers.DecisionTransformerGPT2Model",title:"DecisionTransformerGPT2Model"},{local:"transformers.DecisionTransformerModel",title:"DecisionTransformerModel"}],title:"Decision Transformer"};function Vt(R){return Et(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class tn extends Wt{constructor(l){super(),Bt(this,l,Vt,Pt,zt,{})}}export{tn as component};
