import{s as He,o as Ve,n as ge}from"../chunks/scheduler.25b97de1.js";import{S as Se,i as qe,g as d,s as i,r as u,A as Ie,h as m,f as r,c as l,j as A,u as y,x as v,k as K,y as h,a,v as _,d as T,t as b,w as j}from"../chunks/index.d9030fc9.js";import{T as Ne}from"../chunks/Tip.baa67368.js";import{D as $e}from"../chunks/Docstring.e257edda.js";import{C as Fe}from"../chunks/CodeBlock.e6cd0d95.js";import{E as Ye}from"../chunks/ExampleCodeBlock.20db4b6e.js";import{H as ee,E as Ee}from"../chunks/EditOnGithub.91d95064.js";function Qe(x){let o,p="This model is in maintenance mode only, so we won’t accept any new PRs changing its code.",n,c,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(){o=d("p"),o.textContent=p,n=i(),c=d("p"),c.innerHTML=g},l(s){o=m(s,"P",{"data-svelte-h":!0}),v(o)!=="svelte-lwu440"&&(o.textContent=p),n=l(s),c=m(s,"P",{"data-svelte-h":!0}),v(c)!=="svelte-4042uy"&&(c.innerHTML=g)},m(s,f){a(s,o,f),a(s,n,f),a(s,c,f)},p:ge,d(s){s&&(r(o),r(n),r(c))}}}function Pe(x){let o,p;return o=new Fe({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`,wrap:!1}}),{c(){u(o.$$.fragment)},l(n){y(o.$$.fragment,n)},m(n,c){_(o,n,c),p=!0},p:ge,i(n){p||(T(o.$$.fragment,n),p=!0)},o(n){b(o.$$.fragment,n),p=!1},d(n){j(o,n)}}}function Be(x){let o,p=`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(){o=d("p"),o.innerHTML=p},l(n){o=m(n,"P",{"data-svelte-h":!0}),v(o)!=="svelte-fincs2"&&(o.innerHTML=p)},m(n,c){a(n,o,c)},p:ge,d(n){n&&r(o)}}}function Xe(x){let o,p="Examples:",n,c,g;return c=new Fe({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>)`,wrap:!1}}),{c(){o=d("p"),o.textContent=p,n=i(),u(c.$$.fragment)},l(s){o=m(s,"P",{"data-svelte-h":!0}),v(o)!=="svelte-kvfsh7"&&(o.textContent=p),n=l(s),y(c.$$.fragment,s)},m(s,f){a(s,o,f),a(s,n,f),_(c,s,f),g=!0},p:ge,i(s){g||(T(c.$$.fragment,s),g=!0)},o(s){b(c.$$.fragment,s),g=!1},d(s){s&&(r(o),r(n)),j(c,s)}}}function De(x){let o,p,n,c,g,s,f,te,R,oe,z,Ce='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.',re,G,Ue="The abstract from the paper is the following:",ne,L,ke=`<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>`,ae,N,xe='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>.',se,Y,ie,F,Je=`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).`,le,H,ce,w,V,ue,Q,Ze=`This is the configuration class to store the configuration of a <a href="/docs/transformers/pr_30136/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.`,ye,P,We=`Configuration objects inherit from <a href="/docs/transformers/pr_30136/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/pr_30136/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,_e,J,de,S,me,M,q,Te,B,Re=`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.`,be,X,ze="the full GPT language model, with a context size of block_size",je,$,I,ve,D,Ge='The <a href="/docs/transformers/pr_30136/en/model_doc/trajectory_transformer#transformers.TrajectoryTransformerModel">TrajectoryTransformerModel</a> forward method, overrides the <code>__call__</code> special method.',we,Z,Me,W,pe,E,fe,O,he;return g=new ee({props:{title:"Trajectory Transformer",local:"trajectory-transformer",headingTag:"h1"}}),f=new Ne({props:{warning:!0,$$slots:{default:[Qe]},$$scope:{ctx:x}}}),R=new ee({props:{title:"Overview",local:"overview",headingTag:"h2"}}),Y=new ee({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),H=new ee({props:{title:"TrajectoryTransformerConfig",local:"transformers.TrajectoryTransformerConfig",headingTag:"h2"}}),V=new $e({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/pr_30136/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/vr_30136/src/transformers/models/deprecated/trajectory_transformer/configuration_trajectory_transformer.py#L24"}}),J=new Ye({props:{anchor:"transformers.TrajectoryTransformerConfig.example",$$slots:{default:[Pe]},$$scope:{ctx:x}}}),S=new ee({props:{title:"TrajectoryTransformerModel",local:"transformers.TrajectoryTransformerModel",headingTag:"h2"}}),q=new $e({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/pr_30136/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/pr_30136/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/vr_30136/src/transformers/models/deprecated/trajectory_transformer/modeling_trajectory_transformer.py#L394"}}),I=new $e({props:{name:"forward",anchor:"transformers.TrajectoryTransformerModel.forward",parameters:[{name:"trajectories",val:": Optional = None"},{name:"past_key_values",val:": Optional = None"},{name:"targets",val:": Optional = None"},{name:"attention_mask",val:": Optional = None"},{name:"use_cache",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = 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/pr_30136/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/vr_30136/src/transformers/models/deprecated/trajectory_transformer/modeling_trajectory_transformer.py#L459",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<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/pr_30136/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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.deprecated.trajectory_transformer.modeling_trajectory_transformer.TrajectoryTransformerOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Z=new Ne({props:{$$slots:{default:[Be]},$$scope:{ctx:x}}}),W=new Ye({props:{anchor:"transformers.TrajectoryTransformerModel.forward.example",$$slots:{default:[Xe]},$$scope:{ctx:x}}}),E=new Ee({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/trajectory_transformer.md"}}),{c(){o=d("meta"),p=i(),n=d("p"),c=i(),u(g.$$.fragment),s=i(),u(f.$$.fragment),te=i(),u(R.$$.fragment),oe=i(),z=d("p"),z.innerHTML=Ce,re=i(),G=d("p"),G.textContent=Ue,ne=i(),L=d("p"),L.innerHTML=ke,ae=i(),N=d("p"),N.innerHTML=xe,se=i(),u(Y.$$.fragment),ie=i(),F=d("p"),F.textContent=Je,le=i(),u(H.$$.fragment),ce=i(),w=d("div"),u(V.$$.fragment),ue=i(),Q=d("p"),Q.innerHTML=Ze,ye=i(),P=d("p"),P.innerHTML=We,_e=i(),u(J.$$.fragment),de=i(),u(S.$$.fragment),me=i(),M=d("div"),u(q.$$.fragment),Te=i(),B=d("p"),B.innerHTML=Re,be=i(),X=d("p"),X.textContent=ze,je=i(),$=d("div"),u(I.$$.fragment),ve=i(),D=d("p"),D.innerHTML=Ge,we=i(),u(Z.$$.fragment),Me=i(),u(W.$$.fragment),pe=i(),u(E.$$.fragment),fe=i(),O=d("p"),this.h()},l(e){const t=Ie("svelte-u9bgzb",document.head);o=m(t,"META",{name:!0,content:!0}),t.forEach(r),p=l(e),n=m(e,"P",{}),A(n).forEach(r),c=l(e),y(g.$$.fragment,e),s=l(e),y(f.$$.fragment,e),te=l(e),y(R.$$.fragment,e),oe=l(e),z=m(e,"P",{"data-svelte-h":!0}),v(z)!=="svelte-phmc4q"&&(z.innerHTML=Ce),re=l(e),G=m(e,"P",{"data-svelte-h":!0}),v(G)!=="svelte-vfdo9a"&&(G.textContent=Ue),ne=l(e),L=m(e,"P",{"data-svelte-h":!0}),v(L)!=="svelte-1bgey0r"&&(L.innerHTML=ke),ae=l(e),N=m(e,"P",{"data-svelte-h":!0}),v(N)!=="svelte-1usegnj"&&(N.innerHTML=xe),se=l(e),y(Y.$$.fragment,e),ie=l(e),F=m(e,"P",{"data-svelte-h":!0}),v(F)!=="svelte-1kke2bv"&&(F.textContent=Je),le=l(e),y(H.$$.fragment,e),ce=l(e),w=m(e,"DIV",{class:!0});var C=A(w);y(V.$$.fragment,C),ue=l(C),Q=m(C,"P",{"data-svelte-h":!0}),v(Q)!=="svelte-eezbcd"&&(Q.innerHTML=Ze),ye=l(C),P=m(C,"P",{"data-svelte-h":!0}),v(P)!=="svelte-k9hyr"&&(P.innerHTML=We),_e=l(C),y(J.$$.fragment,C),C.forEach(r),de=l(e),y(S.$$.fragment,e),me=l(e),M=m(e,"DIV",{class:!0});var U=A(M);y(q.$$.fragment,U),Te=l(U),B=m(U,"P",{"data-svelte-h":!0}),v(B)!=="svelte-d660au"&&(B.innerHTML=Re),be=l(U),X=m(U,"P",{"data-svelte-h":!0}),v(X)!=="svelte-1oiyixz"&&(X.textContent=ze),je=l(U),$=m(U,"DIV",{class:!0});var k=A($);y(I.$$.fragment,k),ve=l(k),D=m(k,"P",{"data-svelte-h":!0}),v(D)!=="svelte-ax870n"&&(D.innerHTML=Ge),we=l(k),y(Z.$$.fragment,k),Me=l(k),y(W.$$.fragment,k),k.forEach(r),U.forEach(r),pe=l(e),y(E.$$.fragment,e),fe=l(e),O=m(e,"P",{}),A(O).forEach(r),this.h()},h(){K(o,"name","hf:doc:metadata"),K(o,"content",Oe),K(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),K($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),K(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,t){h(document.head,o),a(e,p,t),a(e,n,t),a(e,c,t),_(g,e,t),a(e,s,t),_(f,e,t),a(e,te,t),_(R,e,t),a(e,oe,t),a(e,z,t),a(e,re,t),a(e,G,t),a(e,ne,t),a(e,L,t),a(e,ae,t),a(e,N,t),a(e,se,t),_(Y,e,t),a(e,ie,t),a(e,F,t),a(e,le,t),_(H,e,t),a(e,ce,t),a(e,w,t),_(V,w,null),h(w,ue),h(w,Q),h(w,ye),h(w,P),h(w,_e),_(J,w,null),a(e,de,t),_(S,e,t),a(e,me,t),a(e,M,t),_(q,M,null),h(M,Te),h(M,B),h(M,be),h(M,X),h(M,je),h(M,$),_(I,$,null),h($,ve),h($,D),h($,we),_(Z,$,null),h($,Me),_(W,$,null),a(e,pe,t),_(E,e,t),a(e,fe,t),a(e,O,t),he=!0},p(e,[t]){const C={};t&2&&(C.$$scope={dirty:t,ctx:e}),f.$set(C);const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),J.$set(U);const k={};t&2&&(k.$$scope={dirty:t,ctx:e}),Z.$set(k);const Le={};t&2&&(Le.$$scope={dirty:t,ctx:e}),W.$set(Le)},i(e){he||(T(g.$$.fragment,e),T(f.$$.fragment,e),T(R.$$.fragment,e),T(Y.$$.fragment,e),T(H.$$.fragment,e),T(V.$$.fragment,e),T(J.$$.fragment,e),T(S.$$.fragment,e),T(q.$$.fragment,e),T(I.$$.fragment,e),T(Z.$$.fragment,e),T(W.$$.fragment,e),T(E.$$.fragment,e),he=!0)},o(e){b(g.$$.fragment,e),b(f.$$.fragment,e),b(R.$$.fragment,e),b(Y.$$.fragment,e),b(H.$$.fragment,e),b(V.$$.fragment,e),b(J.$$.fragment,e),b(S.$$.fragment,e),b(q.$$.fragment,e),b(I.$$.fragment,e),b(Z.$$.fragment,e),b(W.$$.fragment,e),b(E.$$.fragment,e),he=!1},d(e){e&&(r(p),r(n),r(c),r(s),r(te),r(oe),r(z),r(re),r(G),r(ne),r(L),r(ae),r(N),r(se),r(ie),r(F),r(le),r(ce),r(w),r(de),r(me),r(M),r(pe),r(fe),r(O)),r(o),j(g,e),j(f,e),j(R,e),j(Y,e),j(H,e),j(V),j(J),j(S,e),j(q),j(I),j(Z),j(W),j(E,e)}}}const Oe='{"title":"Trajectory Transformer","local":"trajectory-transformer","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"TrajectoryTransformerConfig","local":"transformers.TrajectoryTransformerConfig","sections":[],"depth":2},{"title":"TrajectoryTransformerModel","local":"transformers.TrajectoryTransformerModel","sections":[],"depth":2}],"depth":1}';function Ae(x){return Ve(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class st extends Se{constructor(o){super(),qe(this,o,Ae,De,He,{})}}export{st as component};
