import{s as vt,o as bt,n as Ne}from"../chunks/scheduler.9bc65507.js";import{S as wt,i as jt,g as n,s as d,u as b,A as Mt,h as a,f as t,c as m,j as y,v as w,y as f,k as p,o as l,a as s,w as j,d as M,t as C,x as $}from"../chunks/index.78c82d43.js";import{T as yt}from"../chunks/Tip.87d55b76.js";import{D as Xe}from"../chunks/Docstring.f3d04bd2.js";import{C as Tt}from"../chunks/CodeBlock.48618ec2.js";import{I as ze}from"../chunks/IconCopyLink.bedaa44d.js";import{E as _t}from"../chunks/ExampleCodeBlock.872b014d.js";function Ct(x){let r,u="This model is in maintenance mode only, so we won’t accept any new PRs changing its code.",c,h,g=`If you run into any issues running this model, please reinstall the last version that supported this model: v4.30.0.
You can do so by running the following command: <code>pip install -U transformers==4.30.0</code>.`;return{c(){r=n("p"),r.textContent=u,c=d(),h=n("p"),h.innerHTML=g},l(i){r=a(i,"P",{"data-svelte-h":!0}),f(r)!=="svelte-lwu440"&&(r.textContent=u),c=m(i),h=a(i,"P",{"data-svelte-h":!0}),f(h)!=="svelte-4042uy"&&(h.innerHTML=g)},m(i,_){s(i,r,_),s(i,c,_),s(i,h,_)},p:Ne,d(i){i&&(t(r),t(c),t(h))}}}function $t(x){let r,u;return r=new Tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWplY3RvcnlUcmFuc2Zvcm1lckNvbmZpZyUyQyUyMFRyYWplY3RvcnlUcmFuc2Zvcm1lck1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFRyYWplY3RvcnlUcmFuc2Zvcm1lciUyMENhcmxDb2NoZXQlMkZ0cmFqZWN0b3J5LXRyYW5zZm9ybWVyLWhhbGZjaGVldGFoLW1lZGl1bS12MiUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBUcmFqZWN0b3J5VHJhbnNmb3JtZXJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwQ2FybENvY2hldCUyRnRyYWplY3RvcnktdHJhbnNmb3JtZXItaGFsZmNoZWV0YWgtbWVkaXVtLXYyJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBUcmFqZWN0b3J5VHJhbnNmb3JtZXJNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrajectoryTransformerConfig, TrajectoryTransformerModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a TrajectoryTransformer CarlCochet/trajectory-transformer-halfcheetah-medium-v2 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = TrajectoryTransformerConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the CarlCochet/trajectory-transformer-halfcheetah-medium-v2 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TrajectoryTransformerModel(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`}}),{c(){b(r.$$.fragment)},l(c){w(r.$$.fragment,c)},m(c,h){j(r,c,h),u=!0},p:Ne,i(c){u||(M(r.$$.fragment,c),u=!0)},o(c){C(r.$$.fragment,c),u=!1},d(c){$(r,c)}}}function kt(x){let r,u=`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(){r=n("p"),r.innerHTML=u},l(c){r=a(c,"P",{"data-svelte-h":!0}),f(r)!=="svelte-fincs2"&&(r.innerHTML=u)},m(c,h){s(c,r,h)},p:Ne,d(c){c&&t(r)}}}function xt(x){let r,u="Examples:",c,h,g;return h=new Tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWplY3RvcnlUcmFuc2Zvcm1lck1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbCUyMCUzRCUyMFRyYWplY3RvcnlUcmFuc2Zvcm1lck1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJDYXJsQ29jaGV0JTJGdHJhamVjdG9yeS10cmFuc2Zvcm1lci1oYWxmY2hlZXRhaC1tZWRpdW0tdjIlMjIlMEEpJTBBbW9kZWwudG8oZGV2aWNlKSUwQW1vZGVsLmV2YWwoKSUwQSUwQW9ic2VydmF0aW9uc19kaW0lMkMlMjBhY3Rpb25fZGltJTJDJTIwYmF0Y2hfc2l6ZSUyMCUzRCUyMDE3JTJDJTIwNiUyQyUyMDI1NiUwQXNlcV9sZW5ndGglMjAlM0QlMjBvYnNlcnZhdGlvbnNfZGltJTIwJTJCJTIwYWN0aW9uX2RpbSUyMCUyQiUyMDElMEElMEF0cmFqZWN0b3JpZXMlMjAlM0QlMjB0b3JjaC5Mb25nVGVuc29yKCU1Qm5wLnJhbmRvbS5wZXJtdXRhdGlvbihzZWxmLnNlcV9sZW5ndGgpJTIwZm9yJTIwXyUyMGluJTIwcmFuZ2UoYmF0Y2hfc2l6ZSklNUQpLnRvKCUwQSUyMCUyMCUyMCUyMGRldmljZSUwQSklMEF0YXJnZXRzJTIwJTNEJTIwdG9yY2guTG9uZ1RlbnNvciglNUJucC5yYW5kb20ucGVybXV0YXRpb24oc2VsZi5zZXFfbGVuZ3RoKSUyMGZvciUyMF8lMjBpbiUyMHJhbmdlKGJhdGNoX3NpemUpJTVEKS50byhkZXZpY2UpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCUwQSUyMCUyMCUyMCUyMHRyYWplY3RvcmllcyUyQyUwQSUyMCUyMCUyMCUyMHRhcmdldHMlM0R0YXJnZXRzJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2NhY2hlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF9hdHRlbnRpb25zJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG91dHB1dF9oaWRkZW5fc3RhdGVzJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9kaWN0JTNEVHJ1ZSUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrajectoryTransformerModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TrajectoryTransformerModel.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;CarlCochet/trajectory-transformer-halfcheetah-medium-v2&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>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>observations_dim, action_dim, batch_size = <span class="hljs-number">17</span>, <span class="hljs-number">6</span>, <span class="hljs-number">256</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>seq_length = observations_dim + action_dim + <span class="hljs-number">1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>trajectories = torch.LongTensor([np.random.permutation(self.seq_length) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(batch_size)]).to(
<span class="hljs-meta">... </span>    device
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>targets = torch.LongTensor([np.random.permutation(self.seq_length) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(batch_size)]).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(
<span class="hljs-meta">... </span>    trajectories,
<span class="hljs-meta">... </span>    targets=targets,
<span class="hljs-meta">... </span>    use_cache=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    output_attentions=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    output_hidden_states=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    return_dict=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)`}}),{c(){r=n("p"),r.textContent=u,c=d(),b(h.$$.fragment)},l(i){r=a(i,"P",{"data-svelte-h":!0}),f(r)!=="svelte-kvfsh7"&&(r.textContent=u),c=m(i),w(h.$$.fragment,i)},m(i,_){s(i,r,_),s(i,c,_),j(h,i,_),g=!0},p:Ne,i(i){g||(M(h.$$.fragment,i),g=!0)},o(i){C(h.$$.fragment,i),g=!1},d(i){i&&(t(r),t(c)),$(h,i)}}}function Ut(x){let r,u,c,h,g,i,_,Y,Se,re,Ae="Trajectory Transformer",_e,W,Te,U,R,he,V,Ge,ne,De="Overview",ve,q,Oe='The Trajectory Transformer model was proposed in <a href="https://arxiv.org/abs/2106.02039" rel="nofollow">Offline Reinforcement Learning as One Big Sequence Modeling Problem</a>  by Michael Janner, Qiyang Li, Sergey Levine.',be,P,Ke="The abstract from the paper is the following:",we,I,et=`<em>Reinforcement learning (RL) is typically concerned with estimating stationary policies or single-step models,
leveraging the Markov property to factorize problems in time. However, we can also view RL as a generic sequence
modeling problem, with the goal being to produce a sequence of actions that leads to a sequence of high rewards.
Viewed in this way, it is tempting to consider whether high-capacity sequence prediction models that work well
in other domains, such as natural-language processing, can also provide effective solutions to the RL problem.
To this end, we explore how RL can be tackled with the tools of sequence modeling, using a Transformer architecture
to model distributions over trajectories and repurposing beam search as a planning algorithm. Framing RL as sequence
modeling problem simplifies a range of design decisions, allowing us to dispense with many of the components common
in offline RL algorithms. We demonstrate the flexibility of this approach across long-horizon dynamics prediction,
imitation learning, goal-conditioned RL, and offline RL. Further, we show that this approach can be combined with
existing model-free algorithms to yield a state-of-the-art planner in sparse-reward, long-horizon tasks.</em>`,je,Q,tt="Tips:",Me,B,ot=`This Transformer is used for deep reinforcement learning. To use it, you need to create sequences from
actions, states and rewards from all previous timesteps. This model will treat all these elements together
as one big sequence (a trajectory).`,Ce,X,rt='This model was contributed by <a href="https://huggingface.co/CarlCochet" rel="nofollow">CarlCochet</a>. The original code can be found <a href="https://github.com/jannerm/trajectory-transformer" rel="nofollow">here</a>.',$e,J,z,pe,A,Le,ae,nt="TrajectoryTransformerConfig",ke,T,D,Ee,se,at=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.33.3/en/model_doc/trajectory_transformer#transformers.TrajectoryTransformerModel">TrajectoryTransformerModel</a>. It is used to
instantiate an TrajectoryTransformer 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
TrajectoryTransformer
<a href="https://huggingface.co/CarlCochet/trajectory-transformer-halfcheetah-medium-v2" rel="nofollow">CarlCochet/trajectory-transformer-halfcheetah-medium-v2</a>
architecture.`,Fe,ie,st=`Configuration objects inherit from <a href="/docs/transformers/v4.33.3/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.33.3/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,He,N,xe,Z,S,fe,O,Ye,le,it="TrajectoryTransformerModel",Ue,v,K,Ve,ce,lt=`The bare TrajectoryTransformer Model transformer outputting raw hidden-states without any specific head on top.
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.`,qe,de,ct="the full GPT language model, with a context size of block_size",Pe,k,ee,Ie,me,dt='The <a href="/docs/transformers/v4.33.3/en/model_doc/trajectory_transformer#transformers.TrajectoryTransformerModel">TrajectoryTransformerModel</a> forward method, overrides the <code>__call__</code> special method.',Qe,G,Be,L,Je,ue,Ze;return Y=new ze({}),W=new yt({props:{warning:!0,$$slots:{default:[Ct]},$$scope:{ctx:x}}}),V=new ze({}),A=new ze({}),D=new Xe({props:{name:"class transformers.TrajectoryTransformerConfig",anchor:"transformers.TrajectoryTransformerConfig",parameters:[{name:"vocab_size",val:" = 100"},{name:"action_weight",val:" = 5"},{name:"reward_weight",val:" = 1"},{name:"value_weight",val:" = 1"},{name:"block_size",val:" = 249"},{name:"action_dim",val:" = 6"},{name:"observation_dim",val:" = 17"},{name:"transition_dim",val:" = 25"},{name:"n_layer",val:" = 4"},{name:"n_head",val:" = 4"},{name:"n_embd",val:" = 128"},{name:"embd_pdrop",val:" = 0.1"},{name:"attn_pdrop",val:" = 0.1"},{name:"resid_pdrop",val:" = 0.1"},{name:"learning_rate",val:" = 0.0006"},{name:"max_position_embeddings",val:" = 512"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"kaiming_initializer_range",val:" = 1"},{name:"use_cache",val:" = True"},{name:"pad_token_id",val:" = 1"},{name:"bos_token_id",val:" = 50256"},{name:"eos_token_id",val:" = 50256"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TrajectoryTransformerConfig.vocab_size",description:`<strong>vocab_size</strong> (<code>int</code>, <em>optional</em>, defaults to 100) &#x2014;
Vocabulary size of the TrajectoryTransformer model. Defines the number of different tokens that can be
represented by the <code>trajectories</code> passed when calling <a href="/docs/transformers/v4.33.3/en/model_doc/trajectory_transformer#transformers.TrajectoryTransformerModel">TrajectoryTransformerModel</a>`,name:"vocab_size"},{anchor:"transformers.TrajectoryTransformerConfig.action_weight",description:`<strong>action_weight</strong> (<code>int</code>, <em>optional</em>, defaults to 5) &#x2014;
Weight of the action in the loss function`,name:"action_weight"},{anchor:"transformers.TrajectoryTransformerConfig.reward_weight",description:`<strong>reward_weight</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Weight of the reward in the loss function`,name:"reward_weight"},{anchor:"transformers.TrajectoryTransformerConfig.value_weight",description:`<strong>value_weight</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Weight of the value in the loss function`,name:"value_weight"},{anchor:"transformers.TrajectoryTransformerConfig.block_size",description:`<strong>block_size</strong> (<code>int</code>, <em>optional</em>, defaults to 249) &#x2014;
Size of the blocks in the trajectory transformer.`,name:"block_size"},{anchor:"transformers.TrajectoryTransformerConfig.action_dim",description:`<strong>action_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 6) &#x2014;
Dimension of the action space.`,name:"action_dim"},{anchor:"transformers.TrajectoryTransformerConfig.observation_dim",description:`<strong>observation_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 17) &#x2014;
Dimension of the observation space.`,name:"observation_dim"},{anchor:"transformers.TrajectoryTransformerConfig.transition_dim",description:`<strong>transition_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 25) &#x2014;
Dimension of the transition space.`,name:"transition_dim"},{anchor:"transformers.TrajectoryTransformerConfig.n_layer",description:`<strong>n_layer</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"n_layer"},{anchor:"transformers.TrajectoryTransformerConfig.n_head",description:`<strong>n_head</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"n_head"},{anchor:"transformers.TrajectoryTransformerConfig.n_embd",description:`<strong>n_embd</strong> (<code>int</code>, <em>optional</em>, defaults to 128) &#x2014;
Dimensionality of the embeddings and hidden states.`,name:"n_embd"},{anchor:"transformers.TrajectoryTransformerConfig.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.TrajectoryTransformerConfig.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.TrajectoryTransformerConfig.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.TrajectoryTransformerConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.TrajectoryTransformerConfig.max_position_embeddings",description:`<strong>max_position_embeddings</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#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:"max_position_embeddings"},{anchor:"transformers.TrajectoryTransformerConfig.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.TrajectoryTransformerConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.TrajectoryTransformerConfig.kaiming_initializer_range",description:"<strong>kaiming_initializer_range</strong> (`float, <em>optional</em>, defaults to 1) &#x2014;\nA coefficient scaling the negative slope of the kaiming initializer rectifier for EinLinear layers.",name:"kaiming_initializer_range"},{anchor:"transformers.TrajectoryTransformerConfig.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). Only
relevant if <code>config.is_decoder=True</code>.
Example &#x2014;`,name:"use_cache"}],source:"https://github.com/huggingface/transformers/blob/v4.33.3/src/transformers/models/deprecated/trajectory_transformer/configuration_trajectory_transformer.py#L31"}}),N=new _t({props:{anchor:"transformers.TrajectoryTransformerConfig.example",$$slots:{default:[$t]},$$scope:{ctx:x}}}),O=new ze({}),K=new Xe({props:{name:"class transformers.TrajectoryTransformerModel",anchor:"transformers.TrajectoryTransformerModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.TrajectoryTransformerModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.3/en/model_doc/trajectory_transformer#transformers.TrajectoryTransformerConfig">TrajectoryTransformerConfig</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.33.3/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.33.3/src/transformers/models/deprecated/trajectory_transformer/modeling_trajectory_transformer.py#L407"}}),ee=new Xe({props:{name:"forward",anchor:"transformers.TrajectoryTransformerModel.forward",parameters:[{name:"trajectories",val:": typing.Optional[torch.LongTensor] = None"},{name:"past_key_values",val:": typing.Optional[typing.Tuple[typing.Tuple[torch.Tensor]]] = None"},{name:"targets",val:": typing.Optional[torch.FloatTensor] = None"},{name:"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"}],parametersDescription:[{anchor:"transformers.TrajectoryTransformerModel.forward.trajectories",description:`<strong>trajectories</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Batch of trajectories, where a trajectory is a sequence of states, actions and rewards.`,name:"trajectories"},{anchor:"transformers.TrajectoryTransformerModel.forward.past_key_values",description:`<strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code> of length <code>config.n_layers</code>, <em>optional</em>) &#x2014;
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
<code>past_key_values</code> output below). Can be used to speed up sequential decoding. The <code>input_ids</code> which have
their past given to this model should not be passed as <code>input_ids</code> as they have already been computed.`,name:"past_key_values"},{anchor:"transformers.TrajectoryTransformerModel.forward.targets",description:`<strong>targets</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Desired targets used to compute the loss.`,name:"targets"},{anchor:"transformers.TrajectoryTransformerModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.</li>
</ul>
<p><a href="../glossary#attention-mask">What are attention masks?</a>`,name:"attention_mask"},{anchor:"transformers.TrajectoryTransformerModel.forward.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
If set to <code>True</code>, <code>past_key_values</code> key value states are returned and can be used to speed up decoding (see
<code>past_key_values</code>).`,name:"use_cache"},{anchor:"transformers.TrajectoryTransformerModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TrajectoryTransformerModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TrajectoryTransformerModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/v4.33.3/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.33.3/src/transformers/models/deprecated/trajectory_transformer/modeling_trajectory_transformer.py#L468",returnDescription:`
<p>A <code>transformers.models.deprecated.trajectory_transformer.modeling_trajectory_transformer.TrajectoryTransformerOutput</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.33.3/en/model_doc/trajectory_transformer#transformers.TrajectoryTransformerConfig"
>TrajectoryTransformerConfig</a>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Language modeling loss.</li>
<li><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, config.vocab_size)</code>) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).</li>
<li><strong>past_key_values</strong> (<code>Tuple[Tuple[torch.Tensor]]</code>, <em>optional</em>, returned when <code>use_cache=True</code> is passed or when <code>config.use_cache=True</code>) — Tuple of length <code>config.n_layers</code>, containing tuples of tensors of shape <code>(batch_size, num_heads, sequence_length, embed_size_per_head)</code>). Contains pre-computed hidden-states (key and values in the
attention blocks) that can be used (see <code>past_key_values</code> input) to speed up sequential decoding.</li>
<li><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>. Hidden-states of the model at the output of each layer
plus the initial embedding outputs.</li>
<li><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>. GPT2Attentions weights after the attention softmax, used to compute the weighted average
in the self-attention heads.</li>
</ul>
`,returnType:`
<p><code>transformers.models.deprecated.trajectory_transformer.modeling_trajectory_transformer.TrajectoryTransformerOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),G=new yt({props:{$$slots:{default:[kt]},$$scope:{ctx:x}}}),L=new _t({props:{anchor:"transformers.TrajectoryTransformerModel.forward.example",$$slots:{default:[xt]},$$scope:{ctx:x}}}),{c(){r=n("meta"),u=d(),c=n("p"),h=d(),g=n("h1"),i=n("a"),_=n("span"),b(Y.$$.fragment),Se=d(),re=n("span"),re.textContent=Ae,_e=d(),b(W.$$.fragment),Te=d(),U=n("h2"),R=n("a"),he=n("span"),b(V.$$.fragment),Ge=d(),ne=n("span"),ne.textContent=De,ve=d(),q=n("p"),q.innerHTML=Oe,be=d(),P=n("p"),P.textContent=Ke,we=d(),I=n("p"),I.innerHTML=et,je=d(),Q=n("p"),Q.textContent=tt,Me=d(),B=n("p"),B.textContent=ot,Ce=d(),X=n("p"),X.innerHTML=rt,$e=d(),J=n("h2"),z=n("a"),pe=n("span"),b(A.$$.fragment),Le=d(),ae=n("span"),ae.textContent=nt,ke=d(),T=n("div"),b(D.$$.fragment),Ee=d(),se=n("p"),se.innerHTML=at,Fe=d(),ie=n("p"),ie.innerHTML=st,He=d(),b(N.$$.fragment),xe=d(),Z=n("h2"),S=n("a"),fe=n("span"),b(O.$$.fragment),Ye=d(),le=n("span"),le.textContent=it,Ue=d(),v=n("div"),b(K.$$.fragment),Ve=d(),ce=n("p"),ce.innerHTML=lt,qe=d(),de=n("p"),de.textContent=ct,Pe=d(),k=n("div"),b(ee.$$.fragment),Ie=d(),me=n("p"),me.innerHTML=dt,Qe=d(),b(G.$$.fragment),Be=d(),b(L.$$.fragment),Je=d(),ue=n("p"),this.h()},l(e){const o=Mt("svelte-1phssyn",document.head);r=a(o,"META",{name:!0,content:!0}),o.forEach(t),u=m(e),c=a(e,"P",{}),y(c).forEach(t),h=m(e),g=a(e,"H1",{class:!0});var te=y(g);i=a(te,"A",{id:!0,class:!0,href:!0});var ge=y(i);_=a(ge,"SPAN",{});var ye=y(_);w(Y.$$.fragment,ye),ye.forEach(t),ge.forEach(t),Se=m(te),re=a(te,"SPAN",{"data-svelte-h":!0}),f(re)!=="svelte-1kgfj6b"&&(re.textContent=Ae),te.forEach(t),_e=m(e),w(W.$$.fragment,e),Te=m(e),U=a(e,"H2",{class:!0});var oe=y(U);R=a(oe,"A",{id:!0,class:!0,href:!0});var mt=y(R);he=a(mt,"SPAN",{});var ht=y(he);w(V.$$.fragment,ht),ht.forEach(t),mt.forEach(t),Ge=m(oe),ne=a(oe,"SPAN",{"data-svelte-h":!0}),f(ne)!=="svelte-1jsw1pg"&&(ne.textContent=De),oe.forEach(t),ve=m(e),q=a(e,"P",{"data-svelte-h":!0}),f(q)!=="svelte-phmc4q"&&(q.innerHTML=Oe),be=m(e),P=a(e,"P",{"data-svelte-h":!0}),f(P)!=="svelte-vfdo9a"&&(P.textContent=Ke),we=m(e),I=a(e,"P",{"data-svelte-h":!0}),f(I)!=="svelte-1bgey0r"&&(I.innerHTML=et),je=m(e),Q=a(e,"P",{"data-svelte-h":!0}),f(Q)!=="svelte-axv494"&&(Q.textContent=tt),Me=m(e),B=a(e,"P",{"data-svelte-h":!0}),f(B)!=="svelte-1kke2bv"&&(B.textContent=ot),Ce=m(e),X=a(e,"P",{"data-svelte-h":!0}),f(X)!=="svelte-1usegnj"&&(X.innerHTML=rt),$e=m(e),J=a(e,"H2",{class:!0});var We=y(J);z=a(We,"A",{id:!0,class:!0,href:!0});var pt=y(z);pe=a(pt,"SPAN",{});var ft=y(pe);w(A.$$.fragment,ft),ft.forEach(t),pt.forEach(t),Le=m(We),ae=a(We,"SPAN",{"data-svelte-h":!0}),f(ae)!=="svelte-f83n7l"&&(ae.textContent=nt),We.forEach(t),ke=m(e),T=a(e,"DIV",{class:!0});var E=y(T);w(D.$$.fragment,E),Ee=m(E),se=a(E,"P",{"data-svelte-h":!0}),f(se)!=="svelte-64y0ba"&&(se.innerHTML=at),Fe=m(E),ie=a(E,"P",{"data-svelte-h":!0}),f(ie)!=="svelte-cfh5wl"&&(ie.innerHTML=st),He=m(E),w(N.$$.fragment,E),E.forEach(t),xe=m(e),Z=a(e,"H2",{class:!0});var Re=y(Z);S=a(Re,"A",{id:!0,class:!0,href:!0});var ut=y(S);fe=a(ut,"SPAN",{});var gt=y(fe);w(O.$$.fragment,gt),gt.forEach(t),ut.forEach(t),Ye=m(Re),le=a(Re,"SPAN",{"data-svelte-h":!0}),f(le)!=="svelte-3v3pe2"&&(le.textContent=it),Re.forEach(t),Ue=m(e),v=a(e,"DIV",{class:!0});var F=y(v);w(K.$$.fragment,F),Ve=m(F),ce=a(F,"P",{"data-svelte-h":!0}),f(ce)!=="svelte-d660au"&&(ce.innerHTML=lt),qe=m(F),de=a(F,"P",{"data-svelte-h":!0}),f(de)!=="svelte-1oiyixz"&&(de.textContent=ct),Pe=m(F),k=a(F,"DIV",{class:!0});var H=y(k);w(ee.$$.fragment,H),Ie=m(H),me=a(H,"P",{"data-svelte-h":!0}),f(me)!=="svelte-c2fb2q"&&(me.innerHTML=dt),Qe=m(H),w(G.$$.fragment,H),Be=m(H),w(L.$$.fragment,H),H.forEach(t),F.forEach(t),Je=m(e),ue=a(e,"P",{}),y(ue).forEach(t),this.h()},h(){p(r,"name","hf:doc:metadata"),p(r,"content",JSON.stringify(Jt)),p(i,"id","trajectory-transformer"),p(i,"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"),p(i,"href","#trajectory-transformer"),p(g,"class","relative group"),p(R,"id","overview"),p(R,"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"),p(R,"href","#overview"),p(U,"class","relative group"),p(z,"id","transformers.TrajectoryTransformerConfig"),p(z,"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"),p(z,"href","#transformers.TrajectoryTransformerConfig"),p(J,"class","relative group"),p(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(S,"id","transformers.TrajectoryTransformerModel"),p(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"),p(S,"href","#transformers.TrajectoryTransformerModel"),p(Z,"class","relative group"),p(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(v,"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,o){l(document.head,r),s(e,u,o),s(e,c,o),s(e,h,o),s(e,g,o),l(g,i),l(i,_),j(Y,_,null),l(g,Se),l(g,re),s(e,_e,o),j(W,e,o),s(e,Te,o),s(e,U,o),l(U,R),l(R,he),j(V,he,null),l(U,Ge),l(U,ne),s(e,ve,o),s(e,q,o),s(e,be,o),s(e,P,o),s(e,we,o),s(e,I,o),s(e,je,o),s(e,Q,o),s(e,Me,o),s(e,B,o),s(e,Ce,o),s(e,X,o),s(e,$e,o),s(e,J,o),l(J,z),l(z,pe),j(A,pe,null),l(J,Le),l(J,ae),s(e,ke,o),s(e,T,o),j(D,T,null),l(T,Ee),l(T,se),l(T,Fe),l(T,ie),l(T,He),j(N,T,null),s(e,xe,o),s(e,Z,o),l(Z,S),l(S,fe),j(O,fe,null),l(Z,Ye),l(Z,le),s(e,Ue,o),s(e,v,o),j(K,v,null),l(v,Ve),l(v,ce),l(v,qe),l(v,de),l(v,Pe),l(v,k),j(ee,k,null),l(k,Ie),l(k,me),l(k,Qe),j(G,k,null),l(k,Be),j(L,k,null),s(e,Je,o),s(e,ue,o),Ze=!0},p(e,[o]){const te={};o&2&&(te.$$scope={dirty:o,ctx:e}),W.$set(te);const ge={};o&2&&(ge.$$scope={dirty:o,ctx:e}),N.$set(ge);const ye={};o&2&&(ye.$$scope={dirty:o,ctx:e}),G.$set(ye);const oe={};o&2&&(oe.$$scope={dirty:o,ctx:e}),L.$set(oe)},i(e){Ze||(M(Y.$$.fragment,e),M(W.$$.fragment,e),M(V.$$.fragment,e),M(A.$$.fragment,e),M(D.$$.fragment,e),M(N.$$.fragment,e),M(O.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(G.$$.fragment,e),M(L.$$.fragment,e),Ze=!0)},o(e){C(Y.$$.fragment,e),C(W.$$.fragment,e),C(V.$$.fragment,e),C(A.$$.fragment,e),C(D.$$.fragment,e),C(N.$$.fragment,e),C(O.$$.fragment,e),C(K.$$.fragment,e),C(ee.$$.fragment,e),C(G.$$.fragment,e),C(L.$$.fragment,e),Ze=!1},d(e){e&&(t(u),t(c),t(h),t(g),t(_e),t(Te),t(U),t(ve),t(q),t(be),t(P),t(we),t(I),t(je),t(Q),t(Me),t(B),t(Ce),t(X),t($e),t(J),t(ke),t(T),t(xe),t(Z),t(Ue),t(v),t(Je),t(ue)),t(r),$(Y),$(W,e),$(V),$(A),$(D),$(N),$(O),$(K),$(ee),$(G),$(L)}}}const Jt={local:"trajectory-transformer",sections:[{local:"overview",title:"Overview"},{local:"transformers.TrajectoryTransformerConfig",title:"TrajectoryTransformerConfig"},{local:"transformers.TrajectoryTransformerModel",title:"TrajectoryTransformerModel"}],title:"Trajectory Transformer"};function Zt(x){return bt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Et extends wt{constructor(r){super(),jt(this,r,Zt,Ut,vt,{})}}export{Et as component};
