---
local: transformer-xl
sections:
- local: overview
  title: Overview
- local: transformers.TransfoXLConfig
  title: TransfoXLConfig
- local: transformers.TransfoXLTokenizer
  title: TransfoXLTokenizer
- local: transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput
  title: TransfoXL specific outputs
- local: transformers.TransfoXLModel
  title: TransfoXLModel
- local: transformers.TransfoXLLMHeadModel
  title: TransfoXLLMHeadModel
- local: transformers.TransfoXLForSequenceClassification
  title: TransfoXLForSequenceClassification
- local: transformers.TFTransfoXLModel
  title: TFTransfoXLModel
- local: transformers.TFTransfoXLLMHeadModel
  title: TFTransfoXLLMHeadModel
- local: transformers.TFTransfoXLForSequenceClassification
  title: TFTransfoXLForSequenceClassification
- local: transformers.AdaptiveEmbedding
  title: Internal Layers
title: Transformer XL
---
<script>
import Tip from "./Tip.svelte";
import Youtube from "./Youtube.svelte";
import Docstring from "./Docstring.svelte";
import CodeBlock from "./CodeBlock.svelte";
import CodeBlockFw from "./CodeBlockFw.svelte";
import DocNotebookDropdown from "./DocNotebookDropdown.svelte";
import IconCopyLink from "./IconCopyLink.svelte";
export let fw: "pt" | "tf"
</script>
<!--Copyright 2020 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

<h1 id="transformer-xl">Transformer XL</h1>

<h2 id="overview">Overview</h2>

The Transformer-XL model was proposed in [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) by Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V. Le, Ruslan
Salakhutdinov. It's a causal (uni-directional) transformer with relative positioning (sinusoïdal) embeddings which can
reuse previously computed hidden-states to attend to longer context (memory). This model also uses adaptive softmax
inputs and outputs (tied).

The abstract from the paper is the following:

*Transformers have a potential of learning longer-term dependency, but are limited by a fixed-length context in the
setting of language modeling. We propose a novel neural architecture Transformer-XL that enables learning dependency
beyond a fixed length without disrupting temporal coherence. It consists of a segment-level recurrence mechanism and a
novel positional encoding scheme. Our method not only enables capturing longer-term dependency, but also resolves the
context fragmentation problem. As a result, Transformer-XL learns dependency that is 80% longer than RNNs and 450%
longer than vanilla Transformers, achieves better performance on both short and long sequences, and is up to 1,800+
times faster than vanilla Transformers during evaluation. Notably, we improve the state-of-the-art results of
bpc/perplexity to 0.99 on enwiki8, 1.08 on text8, 18.3 on WikiText-103, 21.8 on One Billion Word, and 54.5 on Penn
Treebank (without finetuning). When trained only on WikiText-103, Transformer-XL manages to generate reasonably
coherent, novel text articles with thousands of tokens.*

Tips:

- Transformer-XL uses relative sinusoidal positional embeddings. Padding can be done on the left or on the right. The
  original implementation trains on SQuAD with padding on the left, therefore the padding defaults are set to left.
- Transformer-XL is one of the few models that has no sequence length limit.

This model was contributed by [thomwolf](https://huggingface.co/thomwolf). The original code can be found [here](https://github.com/kimiyoung/transformer-xl).

<Tip warning=&amp;lcub;true}>

TransformerXL does **not** work with *torch.nn.DataParallel* due to a bug in PyTorch, see [issue #36035](https://github.com/pytorch/pytorch/issues/36035)

</Tip>


<h2 id="transformers.TransfoXLConfig">TransfoXLConfig</h2>

<div class="docstring">

<docstring><name>class transformers.TransfoXLConfig</name><anchor>transformers.TransfoXLConfig</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/configuration_transfo_xl.py#L29</source><parameters>[{"name": "vocab_size", "val": " = 267735"}, {"name": "cutoffs", "val": " = [20000, 40000, 200000]"}, {"name": "d_model", "val": " = 1024"}, {"name": "d_embed", "val": " = 1024"}, {"name": "n_head", "val": " = 16"}, {"name": "d_head", "val": " = 64"}, {"name": "d_inner", "val": " = 4096"}, {"name": "div_val", "val": " = 4"}, {"name": "pre_lnorm", "val": " = False"}, {"name": "n_layer", "val": " = 18"}, {"name": "mem_len", "val": " = 1600"}, {"name": "clamp_len", "val": " = 1000"}, {"name": "same_length", "val": " = True"}, {"name": "proj_share_all_but_first", "val": " = True"}, {"name": "attn_type", "val": " = 0"}, {"name": "sample_softmax", "val": " = -1"}, {"name": "adaptive", "val": " = True"}, {"name": "dropout", "val": " = 0.1"}, {"name": "dropatt", "val": " = 0.0"}, {"name": "untie_r", "val": " = True"}, {"name": "init", "val": " = 'normal'"}, {"name": "init_range", "val": " = 0.01"}, {"name": "proj_init_std", "val": " = 0.01"}, {"name": "init_std", "val": " = 0.02"}, {"name": "layer_norm_epsilon", "val": " = 1e-05"}, {"name": "eos_token_id", "val": " = 0"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **vocab_size** (`int`, *optional*, defaults to 267735) --
  Vocabulary size of the BERT model. Defines the number of different tokens that can be represented by the
  `inputs_ids` passed when calling [TransfoXLModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLModel) or [TFTransfoXLModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TFTransfoXLModel).
- **cutoffs** (`List[int]`, *optional*, defaults to `[20000, 40000, 200000]`) --
  Cutoffs for the adaptive softmax.
- **d_model** (`int`, *optional*, defaults to 1024) --
  Dimensionality of the model's hidden states.
- **d_embed** (`int`, *optional*, defaults to 1024) --
  Dimensionality of the embeddings
- **n_head** (`int`, *optional*, defaults to 16) --
  Number of attention heads for each attention layer in the Transformer encoder.
- **d_head** (`int`, *optional*, defaults to 64) --
  Dimensionality of the model's heads.
- **d_inner** (`int`, *optional*, defaults to 4096) --
  Inner dimension in FF
- **div_val** (`int`, *optional*, defaults to 4) --
  Divident value for adapative input and softmax
- **pre_lnorm** (`boolean`, *optional*, defaults to `False`) --
  Whether or not to apply LayerNorm to the input instead of the output in the blocks.
- **n_layer** (`int`, *optional*, defaults to 18) --
  Number of hidden layers in the Transformer encoder.
- **mem_len** (`int`, *optional*, defaults to 1600) --
  Length of the retained previous heads.
- **clamp_len** (`int`, *optional*, defaults to 1000) --
  Use the same pos embeddings after clamp_len.
- **same_length** (`boolean`, *optional*, defaults to `True`) --
  Whether or not to use the same attn length for all tokens
- **proj_share_all_but_first** (`boolean`, *optional*, defaults to `True`) --
  True to share all but first projs, False not to share.
- **attn_type** (`int`, *optional*, defaults to 0) --
  Attention type. 0 for Transformer-XL, 1 for Shaw et al, 2 for Vaswani et al, 3 for Al Rfou et al.
- **sample_softmax** (`int`, *optional*, defaults to -1) --
  Number of samples in the sampled softmax.
- **adaptive** (`boolean`, *optional*, defaults to `True`) --
  Whether or not to use adaptive softmax.
- **dropout** (`float`, *optional*, defaults to 0.1) --
  The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
- **dropatt** (`float`, *optional*, defaults to 0) --
  The dropout ratio for the attention probabilities.
- **untie_r** (`boolean`, *optional*, defaults to `True`) --
  Whether ot not to untie relative position biases.
- **init** (`str`, *optional*, defaults to `"normal"`) --
  Parameter initializer to use.
- **init_range** (`float`, *optional*, defaults to 0.01) --
  Parameters initialized by U(-init_range, init_range).
- **proj_init_std** (`float`, *optional*, defaults to 0.01) --
  Parameters initialized by N(0, init_std)
- **init_std** (`float`, *optional*, defaults to 0.02) --
  Parameters initialized by N(0, init_std)
- **layer_norm_epsilon** (`float`, *optional*, defaults to 1e-5) --
  The epsilon to use in the layer normalization layers</paramsdesc><paramgroups>0</paramgroups></docstring>

This is the configuration class to store the configuration of a [TransfoXLModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLModel) or a [TFTransfoXLModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TFTransfoXLModel). It is
used to instantiate a Transformer-XL 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 [Transformer
XL](https://huggingface.co/transfo-xl-wt103) architecture.

Configuration objects inherit from [PretrainedConfig](/docs/transformers/pr_15592/en/main_classes/configuration#transformers.PretrainedConfig) and can be used to control the model outputs. Read the
documentation from [PretrainedConfig](/docs/transformers/pr_15592/en/main_classes/configuration#transformers.PretrainedConfig) for more information.



Examples:

```python
>>> from transformers import TransfoXLConfig, TransfoXLModel

>>> # Initializing a Transformer XL configuration
>>> configuration = TransfoXLConfig()

>>> # Initializing a model from the configuration
>>> model = TransfoXLModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```

</div>

<h2 id="transformers.TransfoXLTokenizer">TransfoXLTokenizer</h2>

<div class="docstring">

<docstring><name>class transformers.TransfoXLTokenizer</name><anchor>transformers.TransfoXLTokenizer</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/tokenization_transfo_xl.py#L115</source><parameters>[{"name": "special", "val": " = None"}, {"name": "min_freq", "val": " = 0"}, {"name": "max_size", "val": " = None"}, {"name": "lower_case", "val": " = False"}, {"name": "delimiter", "val": " = None"}, {"name": "vocab_file", "val": " = None"}, {"name": "pretrained_vocab_file", "val": ": str = None"}, {"name": "never_split", "val": " = None"}, {"name": "unk_token", "val": " = '<unk>'"}, {"name": "eos_token", "val": " = '<eos>'"}, {"name": "additional_special_tokens", "val": " = ['<formula>']"}, {"name": "language", "val": " = 'en'"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **special** (`List[str]`, *optional*) --
  A list of special tokens (to be treated by the original implementation of this tokenizer).
- **min_freq** (`int`, *optional*, defaults to 0) --
  The minimum number of times a token has to be present in order to be kept in the vocabulary (otherwise it
  will be mapped to `unk_token`).
- **max_size** (`int`, *optional*) --
  The maximum size of the vocabulary. If left unset, it will default to the size of the vocabulary found
  after excluding the tokens according to the `min_freq` rule.
- **lower_case** (`bool`, *optional*, defaults to `False`) --
  Whether or not to lowercase the input when tokenizing.
- **delimiter** (`str`, *optional*) --
  The delimiter used between tokens.
- **vocab_file** (`str`, *optional*) --
  File containing the vocabulary (from the original implementation).
- **pretrained_vocab_file** (`str`, *optional*) --
  File containing the vocabulary as saved with the `save_pretrained()` method.
- **never_split** (`List[str]`, *optional*) --
  List of tokens that should never be split. If no list is specified, will simply use the existing special
  tokens.
- **unk_token** (`str`, *optional*, defaults to `"&amp;lt;unk>"`) --
  The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
  token instead.
- **eos_token** (`str`, *optional*, defaults to `"&amp;lt;eos>"`) --
  The end of sequence token.
- **additional_special_tokens** (`List[str]`, *optional*, defaults to `["&amp;lt;formula>"]`) --
  A list of additional special tokens (for the HuggingFace functionality).
- **language** (`str`, *optional*, defaults to `"en"`) --
  The language of this tokenizer (used for mose preprocessing).</paramsdesc><paramgroups>0</paramgroups></docstring>

Construct a Transformer-XL tokenizer adapted from Vocab class in [the original
code](https://github.com/kimiyoung/transformer-xl). The Transformer-XL tokenizer is a word-level tokenizer (no
sub-word tokenization).

This tokenizer inherits from [PreTrainedTokenizer](/docs/transformers/pr_15592/en/main_classes/tokenizer#transformers.PreTrainedTokenizer) which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.





<div class="docstring"></div></div>

<h2 id="transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput">TransfoXL specific outputs</h2>

<div class="docstring">

<docstring><name>class transformers.models.transfo\_xl.modeling\_transfo\_xl.TransfoXLModelOutput</name><anchor>transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L606</source><parameters>[{"name": "last_hidden_state", "val": ": FloatTensor"}, {"name": "mems", "val": ": typing.List[torch.FloatTensor] = None"}, {"name": "hidden_states", "val": ": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}, {"name": "attentions", "val": ": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}]</parameters><paramsdesc>- **last_hidden_state** (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`) --
  Sequence of hidden-states at the output of the last layer of the model.
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) --
  Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
  shape `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) --
  Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</paramsdesc><paramgroups>0</paramgroups></docstring>

Base class for model's outputs that may also contain a past key/values (to speed up sequential decoding).




</div>

<div class="docstring">

<docstring><name>class transformers.models.transfo\_xl.modeling\_transfo\_xl.TransfoXLLMHeadModelOutput</name><anchor>transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLLMHeadModelOutput</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L671</source><parameters>[{"name": "losses", "val": ": typing.Optional[torch.FloatTensor] = None"}, {"name": "prediction_scores", "val": ": FloatTensor = None"}, {"name": "mems", "val": ": typing.List[torch.FloatTensor] = None"}, {"name": "hidden_states", "val": ": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}, {"name": "attentions", "val": ": typing.Optional[typing.Tuple[torch.FloatTensor]] = None"}]</parameters><paramsdesc>- **losses** (`torch.FloatTensor` of shape *(batch_size, sequence_length-1)*, *optional*, returned when `labels` is provided) --
  Language modeling losses (not reduced).
- **prediction_scores** (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`) --
  Prediction scores of the language modeling head (scores for each vocabulary token after SoftMax).
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) --
  Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
  shape `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) --
  Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</paramsdesc><paramgroups>0</paramgroups></docstring>

Base class for model's outputs that may also contain a past key/values (to speed up sequential decoding).




</div>

<div class="docstring">

<docstring><name>class transformers.models.transfo\_xl.modeling\_tf\_transfo\_xl.TFTransfoXLModelOutput</name><anchor>transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLModelOutput</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L711</source><parameters>[{"name": "last_hidden_state", "val": ": Tensor = None"}, {"name": "mems", "val": ": typing.List[tensorflow.python.framework.ops.Tensor] = None"}, {"name": "hidden_states", "val": ": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"}, {"name": "attentions", "val": ": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"}]</parameters><paramsdesc>- **last_hidden_state** (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`) --
  Sequence of hidden-states at the output of the last layer of the model.
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) --
  Tuple of `tf.Tensor` (one for the output of the embeddings + one for the output of each layer) of shape
  `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(tf.Tensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) --
  Tuple of `tf.Tensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</paramsdesc><paramgroups>0</paramgroups></docstring>

Base class for model's outputs that may also contain a past key/values (to speed up sequential decoding).




</div>

<div class="docstring">

<docstring><name>class transformers.models.transfo\_xl.modeling\_tf\_transfo\_xl.TFTransfoXLLMHeadModelOutput</name><anchor>transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLLMHeadModelOutput</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L742</source><parameters>[{"name": "prediction_scores", "val": ": Tensor = None"}, {"name": "mems", "val": ": typing.List[tensorflow.python.framework.ops.Tensor] = None"}, {"name": "hidden_states", "val": ": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"}, {"name": "attentions", "val": ": typing.Optional[typing.Tuple[tensorflow.python.framework.ops.Tensor]] = None"}]</parameters><paramsdesc>- **losses** (`tf.Tensor` of shape *(batch_size, sequence_length-1)*, *optional*, returned when `labels` is provided) --
  Language modeling losses (not reduced).
- **prediction_scores** (`tf.Tensor` of shape `(batch_size, sequence_length, config.vocab_size)`) --
  Prediction scores of the language modeling head (scores for each vocabulary token after SoftMax).
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) --
  Tuple of `tf.Tensor` (one for the output of the embeddings + one for the output of each layer) of shape
  `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(tf.Tensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) --
  Tuple of `tf.Tensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</paramsdesc><paramgroups>0</paramgroups></docstring>

Base class for model's outputs that may also contain a past key/values (to speed up sequential decoding).




</div>

<h2 id="transformers.TransfoXLModel">TransfoXLModel</h2>

<div class="docstring">

<docstring><name>class transformers.TransfoXLModel</name><anchor>transformers.TransfoXLModel</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L767</source><parameters>[{"name": "config", "val": ""}]</parameters><paramsdesc>- **config** ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) -- 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 [from_pretrained()](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel.from_pretrained) method to load the model weights.</paramsdesc><paramgroups>0</paramgroups></docstring>
The bare Bert Model transformer outputting raw hidden-states without any specific head on top.

This model inherits from [PreTrainedModel](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel). Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)

This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.





<div class="docstring">
<docstring><name>forward</name><anchor>transformers.TransfoXLModel.forward</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L871</source><parameters>[{"name": "input_ids", "val": " = None"}, {"name": "mems", "val": " = None"}, {"name": "head_mask", "val": " = None"}, {"name": "inputs_embeds", "val": " = None"}, {"name": "output_attentions", "val": " = None"}, {"name": "output_hidden_states", "val": " = None"}, {"name": "return_dict", "val": " = None"}]</parameters><paramsdesc>- **input_ids** (`torch.LongTensor` of shape `(batch_size, sequence_length)`) --
  Indices of input sequence tokens in the vocabulary.

  Indices can be obtained using [TransfoXLTokenizer](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLTokenizer). See [PreTrainedTokenizer.encode()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) and
  [PreTrainedTokenizer.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) for details.

  [What are input IDs?](../glossary#input-ids)
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
  `mems` output below). Can be used to speed up sequential decoding. The token ids which have their mems
  given to this model should not be passed as `input_ids` as they have already been computed.
- **head_mask** (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*) --
  Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

  - 1 indicates the head is **not masked**,
  - 0 indicates the head is **masked**.

- **inputs_embeds** (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) --
  Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
  is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
  model's internal embedding lookup matrix.
- **output_attentions** (`bool`, *optional*) --
  Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
  tensors for more detail.
- **output_hidden_states** (`bool`, *optional*) --
  Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
  more detail.
- **return_dict** (`bool`, *optional*) --
  Whether or not to return a [ModelOutput](/docs/transformers/pr_15592/en/main_classes/output#transformers.file_utils.ModelOutput) instead of a plain tuple.</paramsdesc><paramgroups>0</paramgroups><rettype>[transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput) or `tuple(torch.FloatTensor)`</rettype><retdesc>A [transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLModelOutput) or a tuple of
`torch.FloatTensor` (if `return_dict=False` is passed or when `config.return_dict=False`) comprising various
elements depending on the configuration ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) and inputs.

- **last_hidden_state** (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`) -- Sequence of hidden-states at the output of the last layer of the model.
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) -- Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) -- Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
  shape `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) -- Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</retdesc></docstring>
The [TransfoXLModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLModel) forward method, overrides the `__call__` special method.

<Tip>

Although the recipe for forward pass needs to be defined within this function, one should call the `Module`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.

</Tip>







Example:

```python
>>> from transformers import TransfoXLTokenizer, TransfoXLModel
>>> import torch

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TransfoXLModel.from_pretrained("transfo-xl-wt103")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs)

>>> last_hidden_states = outputs.last_hidden_state
```


</div></div>

<h2 id="transformers.TransfoXLLMHeadModel">TransfoXLLMHeadModel</h2>

<div class="docstring">

<docstring><name>class transformers.TransfoXLLMHeadModel</name><anchor>transformers.TransfoXLLMHeadModel</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L1009</source><parameters>[{"name": "config", "val": ""}]</parameters><paramsdesc>- **config** ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) -- 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 [from_pretrained()](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel.from_pretrained) method to load the model weights.</paramsdesc><paramgroups>0</paramgroups></docstring>

The Transformer-XL Model with a language modeling head on top (adaptive softmax with weights tied to the adaptive
input embeddings)


This model inherits from [PreTrainedModel](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel). Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)

This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.





<div class="docstring">
<docstring><name>forward</name><anchor>transformers.TransfoXLLMHeadModel.forward</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L1053</source><parameters>[{"name": "input_ids", "val": " = None"}, {"name": "mems", "val": " = None"}, {"name": "head_mask", "val": " = None"}, {"name": "inputs_embeds", "val": " = None"}, {"name": "labels", "val": " = None"}, {"name": "output_attentions", "val": " = None"}, {"name": "output_hidden_states", "val": " = None"}, {"name": "return_dict", "val": " = None"}]</parameters><paramsdesc>- **input_ids** (`torch.LongTensor` of shape `(batch_size, sequence_length)`) --
  Indices of input sequence tokens in the vocabulary.

  Indices can be obtained using [TransfoXLTokenizer](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLTokenizer). See [PreTrainedTokenizer.encode()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) and
  [PreTrainedTokenizer.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) for details.

  [What are input IDs?](../glossary#input-ids)
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
  `mems` output below). Can be used to speed up sequential decoding. The token ids which have their mems
  given to this model should not be passed as `input_ids` as they have already been computed.
- **head_mask** (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*) --
  Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

  - 1 indicates the head is **not masked**,
  - 0 indicates the head is **masked**.

- **inputs_embeds** (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) --
  Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
  is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
  model's internal embedding lookup matrix.
- **output_attentions** (`bool`, *optional*) --
  Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
  tensors for more detail.
- **output_hidden_states** (`bool`, *optional*) --
  Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
  more detail.
- **return_dict** (`bool`, *optional*) --
  Whether or not to return a [ModelOutput](/docs/transformers/pr_15592/en/main_classes/output#transformers.file_utils.ModelOutput) instead of a plain tuple.

- **labels** (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*) --
  Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
  `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
  are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`</paramsdesc><paramgroups>0</paramgroups><rettype>[transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLLMHeadModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLLMHeadModelOutput) or `tuple(torch.FloatTensor)`</rettype><retdesc>A [transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLLMHeadModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLLMHeadModelOutput) or a tuple of
`torch.FloatTensor` (if `return_dict=False` is passed or when `config.return_dict=False`) comprising various
elements depending on the configuration ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) and inputs.

- **losses** (`torch.FloatTensor` of shape *(batch_size, sequence_length-1)*, *optional*, returned when `labels` is provided) -- Language modeling losses (not reduced).
- **prediction_scores** (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`) -- Prediction scores of the language modeling head (scores for each vocabulary token after SoftMax).
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) -- Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) -- Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
  shape `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) -- Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</retdesc></docstring>
The [TransfoXLLMHeadModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLLMHeadModel) forward method, overrides the `__call__` special method.

<Tip>

Although the recipe for forward pass needs to be defined within this function, one should call the `Module`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.

</Tip>







Example:

```python
>>> import torch
>>> from transformers import TransfoXLTokenizer, TransfoXLLMHeadModel

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TransfoXLLMHeadModel.from_pretrained("transfo-xl-wt103")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs, labels=inputs["input_ids"])
>>> loss = outputs.loss
>>> logits = outputs.logits
```


</div></div>

<h2 id="transformers.TransfoXLForSequenceClassification">TransfoXLForSequenceClassification</h2>

<div class="docstring">

<docstring><name>class transformers.TransfoXLForSequenceClassification</name><anchor>transformers.TransfoXLForSequenceClassification</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L1165</source><parameters>[{"name": "config", "val": ""}]</parameters><paramsdesc>- **config** ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) -- 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 [from_pretrained()](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel.from_pretrained) method to load the model weights.</paramsdesc><paramgroups>0</paramgroups></docstring>

The Transformer-XL Model transformer with a sequence classification head on top (linear layer).

[TransfoXLForSequenceClassification](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLForSequenceClassification) uses the last token in order to do the classification, as other causal
models (e.g. GPT-1) do.

Since it does classification on the last token, it requires to know the position of the last token. If a
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
each row of the batch).


This model inherits from [PreTrainedModel](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel). Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)

This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.





<div class="docstring">
<docstring><name>forward</name><anchor>transformers.TransfoXLForSequenceClassification.forward</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_transfo_xl.py#L1176</source><parameters>[{"name": "input_ids", "val": " = None"}, {"name": "mems", "val": " = None"}, {"name": "head_mask", "val": " = None"}, {"name": "inputs_embeds", "val": " = None"}, {"name": "labels", "val": " = None"}, {"name": "output_attentions", "val": " = None"}, {"name": "output_hidden_states", "val": " = None"}, {"name": "return_dict", "val": " = None"}]</parameters><paramsdesc>- **input_ids** (`torch.LongTensor` of shape `(batch_size, sequence_length)`) --
  Indices of input sequence tokens in the vocabulary.

  Indices can be obtained using [TransfoXLTokenizer](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLTokenizer). See [PreTrainedTokenizer.encode()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) and
  [PreTrainedTokenizer.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) for details.

  [What are input IDs?](../glossary#input-ids)
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
  `mems` output below). Can be used to speed up sequential decoding. The token ids which have their mems
  given to this model should not be passed as `input_ids` as they have already been computed.
- **head_mask** (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*) --
  Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

  - 1 indicates the head is **not masked**,
  - 0 indicates the head is **masked**.

- **inputs_embeds** (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) --
  Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
  is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
  model's internal embedding lookup matrix.
- **output_attentions** (`bool`, *optional*) --
  Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
  tensors for more detail.
- **output_hidden_states** (`bool`, *optional*) --
  Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
  more detail.
- **return_dict** (`bool`, *optional*) --
  Whether or not to return a [ModelOutput](/docs/transformers/pr_15592/en/main_classes/output#transformers.file_utils.ModelOutput) instead of a plain tuple.

- **labels** (`torch.LongTensor` of shape `(batch_size,)`, *optional*) --
  Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
  config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
  `config.num_labels > 1` a classification loss is computed (Cross-Entropy).</paramsdesc><paramgroups>0</paramgroups><rettype>`transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLSequenceClassifierOutputWithPast`or `tuple(torch.FloatTensor)`</rettype><retdesc>A `transformers.models.transfo_xl.modeling_transfo_xl.TransfoXLSequenceClassifierOutputWithPast`or a tuple of
`torch.FloatTensor` (if `return_dict=False` is passed or when `config.return_dict=False`) comprising various
elements depending on the configuration ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) and inputs.

- **loss** (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided) -- Classification (or regression if config.num_labels==1) loss.
- **logits** (`torch.FloatTensor` of shape `(batch_size, config.num_labels)`) -- Classification (or regression if config.num_labels==1) scores (before SoftMax).
- **mems** (`List[torch.FloatTensor]` of length `config.n_layers`) -- Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) -- Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
  shape `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) -- Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</retdesc></docstring>
The [TransfoXLForSequenceClassification](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLForSequenceClassification) forward method, overrides the `__call__` special method.

<Tip>

Although the recipe for forward pass needs to be defined within this function, one should call the `Module`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.

</Tip>







Example of single-label classification:

```python
>>> from transformers import TransfoXLTokenizer, TransfoXLForSequenceClassification
>>> import torch

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TransfoXLForSequenceClassification.from_pretrained("transfo-xl-wt103")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> labels = torch.tensor([1]).unsqueeze(0)  # Batch size 1
>>> outputs = model(**inputs, labels=labels)
>>> loss = outputs.loss
>>> logits = outputs.logits
```

Example of multi-label classification:

```python
>>> from transformers import TransfoXLTokenizer, TransfoXLForSequenceClassification
>>> import torch

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TransfoXLForSequenceClassification.from_pretrained("transfo-xl-wt103", problem_type="multi_label_classification")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> labels = torch.tensor([[1, 1]], dtype=torch.float)  # need dtype=float for BCEWithLogitsLoss
>>> outputs = model(**inputs, labels=labels)
>>> loss = outputs.loss
>>> logits = outputs.logits
```


</div></div>

<h2 id="transformers.TFTransfoXLModel">TFTransfoXLModel</h2>

<div class="docstring">

<docstring><name>class transformers.TFTransfoXLModel</name><anchor>transformers.TFTransfoXLModel</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L888</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **config** ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) -- 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 [from_pretrained()](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel.from_pretrained) method to load the model weights.</paramsdesc><paramgroups>0</paramgroups></docstring>
The bare Bert Model transformer outputting raw hidden-states without any specific head on top.

This model inherits from [TFPreTrainedModel](/docs/transformers/pr_15592/en/main_classes/model#transformers.TFPreTrainedModel). Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)

This model is also a [tf.keras.Model](https://www.tensorflow.org/api_docs/python/tf/keras/Model) subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.

<Tip>

TF 2.0 models accepts two formats as inputs:

- having all inputs as keyword arguments (like PyTorch models), or
- having all inputs as a list, tuple or dict in the first positional arguments.

This second option is useful when using `tf.keras.Model.fit` method which currently requires having all the
tensors in the first argument of the model call function: `model(inputs)`.

If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :

- a single Tensor with `input_ids` only and nothing else: `model(inputs_ids)`
- a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`model([input_ids, attention_mask])` or `model([input_ids, attention_mask, token_type_ids])`
- a dictionary with one or several input Tensors associated to the input names given in the docstring:
`model(&amp;lcub;"input_ids": input_ids, "token_type_ids": token_type_ids})`

</Tip>





<div class="docstring">
<docstring><name>call</name><anchor>transformers.TFTransfoXLModel.call</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L893</source><parameters>[{"name": "input_ids", "val": " = None"}, {"name": "mems", "val": " = None"}, {"name": "head_mask", "val": " = None"}, {"name": "inputs_embeds", "val": " = None"}, {"name": "output_attentions", "val": " = None"}, {"name": "output_hidden_states", "val": " = None"}, {"name": "return_dict", "val": " = None"}, {"name": "training", "val": " = False"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **input_ids** (`tf.Tensor` or `Numpy array` of shape `(batch_size, sequence_length)`) --
  Indices of input sequence tokens in the vocabulary.

  Indices can be obtained using [BertTokenizer](/docs/transformers/pr_15592/en/model_doc/bert#transformers.BertTokenizer). See [PreTrainedTokenizer.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) and
  [PreTrainedTokenizer.encode()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) for details.

  [What are input IDs?](../glossary#input-ids)
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
  `mems` output below). Can be used to speed up sequential decoding. The token ids which have their mems
  given to this model should not be passed as `input_ids` as they have already been computed.
- **head_mask** (`tf.Tensor` or `Numpy array` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*) --
  Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

  - 1 indicates the head is **not masked**,
  - 0 indicates the head is **masked**.
- **inputs_embeds** (`tf.Tensor` or `Numpy array` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) --
  Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
  is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
  model's internal embedding lookup matrix.
- **output_attentions** (`bool`, *optional*) --
  Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
  tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
  config will be used instead.
- **output_hidden_states** (`bool`, *optional*) --
  Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
  more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
  used instead.
- **return_dict** (`bool`, *optional*) --
  Whether or not to return a [ModelOutput](/docs/transformers/pr_15592/en/main_classes/output#transformers.file_utils.ModelOutput) instead of a plain tuple. This argument can be used
  in eager mode, in graph mode the value will always be set to True.
- **training** (`bool`, *optional*, defaults to `False`) --
  Whether or not to use the model in training mode (some modules like dropout modules have different
  behaviors between training and evaluation).</paramsdesc><paramgroups>0</paramgroups><rettype>[transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLModelOutput) or `tuple(tf.Tensor)`</rettype><retdesc>A [transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLModelOutput) or a tuple of `tf.Tensor` (if
`return_dict=False` is passed or when `config.return_dict=False`) comprising various elements depending on the
configuration ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) and inputs.

- **last_hidden_state** (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`) -- Sequence of hidden-states at the output of the last layer of the model.
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) -- Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) -- Tuple of `tf.Tensor` (one for the output of the embeddings + one for the output of each layer) of shape
  `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(tf.Tensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) -- Tuple of `tf.Tensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</retdesc></docstring>
The [TFTransfoXLModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TFTransfoXLModel) forward method, overrides the `__call__` special method.

<Tip>

Although the recipe for forward pass needs to be defined within this function, one should call the `Module`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.

</Tip>







Example:

```python
>>> from transformers import TransfoXLTokenizer, TFTransfoXLModel
>>> import tensorflow as tf

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TFTransfoXLModel.from_pretrained("transfo-xl-wt103")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
>>> outputs = model(inputs)

>>> last_hidden_states = outputs.last_hidden_state
```


</div></div>

<h2 id="transformers.TFTransfoXLLMHeadModel">TFTransfoXLLMHeadModel</h2>

<div class="docstring">

<docstring><name>class transformers.TFTransfoXLLMHeadModel</name><anchor>transformers.TFTransfoXLLMHeadModel</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L957</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **config** ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) -- 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 [from_pretrained()](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel.from_pretrained) method to load the model weights.</paramsdesc><paramgroups>0</paramgroups></docstring>

The Transformer-XL Model with a language modeling head on top (adaptive softmax with weights tied to the adaptive
input embeddings)


This model inherits from [TFPreTrainedModel](/docs/transformers/pr_15592/en/main_classes/model#transformers.TFPreTrainedModel). Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)

This model is also a [tf.keras.Model](https://www.tensorflow.org/api_docs/python/tf/keras/Model) subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.

<Tip>

TF 2.0 models accepts two formats as inputs:

- having all inputs as keyword arguments (like PyTorch models), or
- having all inputs as a list, tuple or dict in the first positional arguments.

This second option is useful when using `tf.keras.Model.fit` method which currently requires having all the
tensors in the first argument of the model call function: `model(inputs)`.

If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :

- a single Tensor with `input_ids` only and nothing else: `model(inputs_ids)`
- a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`model([input_ids, attention_mask])` or `model([input_ids, attention_mask, token_type_ids])`
- a dictionary with one or several input Tensors associated to the input names given in the docstring:
`model(&amp;lcub;"input_ids": input_ids, "token_type_ids": token_type_ids})`

</Tip>





<div class="docstring">
<docstring><name>call</name><anchor>transformers.TFTransfoXLLMHeadModel.call</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L985</source><parameters>[{"name": "input_ids", "val": " = None"}, {"name": "mems", "val": " = None"}, {"name": "head_mask", "val": " = None"}, {"name": "inputs_embeds", "val": " = None"}, {"name": "output_attentions", "val": " = None"}, {"name": "output_hidden_states", "val": " = None"}, {"name": "return_dict", "val": " = None"}, {"name": "labels", "val": " = None"}, {"name": "training", "val": " = False"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **input_ids** (`tf.Tensor` or `Numpy array` of shape `(batch_size, sequence_length)`) --
  Indices of input sequence tokens in the vocabulary.

  Indices can be obtained using [BertTokenizer](/docs/transformers/pr_15592/en/model_doc/bert#transformers.BertTokenizer). See [PreTrainedTokenizer.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) and
  [PreTrainedTokenizer.encode()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) for details.

  [What are input IDs?](../glossary#input-ids)
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
  `mems` output below). Can be used to speed up sequential decoding. The token ids which have their mems
  given to this model should not be passed as `input_ids` as they have already been computed.
- **head_mask** (`tf.Tensor` or `Numpy array` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*) --
  Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

  - 1 indicates the head is **not masked**,
  - 0 indicates the head is **masked**.
- **inputs_embeds** (`tf.Tensor` or `Numpy array` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) --
  Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
  is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
  model's internal embedding lookup matrix.
- **output_attentions** (`bool`, *optional*) --
  Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
  tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
  config will be used instead.
- **output_hidden_states** (`bool`, *optional*) --
  Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
  more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
  used instead.
- **return_dict** (`bool`, *optional*) --
  Whether or not to return a [ModelOutput](/docs/transformers/pr_15592/en/main_classes/output#transformers.file_utils.ModelOutput) instead of a plain tuple. This argument can be used
  in eager mode, in graph mode the value will always be set to True.
- **training** (`bool`, *optional*, defaults to `False`) --
  Whether or not to use the model in training mode (some modules like dropout modules have different
  behaviors between training and evaluation).</paramsdesc><paramgroups>0</paramgroups><rettype>[transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLLMHeadModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLLMHeadModelOutput) or `tuple(tf.Tensor)`</rettype><retdesc>A [transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLLMHeadModelOutput](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLLMHeadModelOutput) or a tuple of `tf.Tensor` (if
`return_dict=False` is passed or when `config.return_dict=False`) comprising various elements depending on the
configuration ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) and inputs.

- **losses** (`tf.Tensor` of shape *(batch_size, sequence_length-1)*, *optional*, returned when `labels` is provided) -- Language modeling losses (not reduced).
- **prediction_scores** (`tf.Tensor` of shape `(batch_size, sequence_length, config.vocab_size)`) -- Prediction scores of the language modeling head (scores for each vocabulary token after SoftMax).
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) -- Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) -- Tuple of `tf.Tensor` (one for the output of the embeddings + one for the output of each layer) of shape
  `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(tf.Tensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) -- Tuple of `tf.Tensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</retdesc></docstring>
The [TFTransfoXLLMHeadModel](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TFTransfoXLLMHeadModel) forward method, overrides the `__call__` special method.

<Tip>

Although the recipe for forward pass needs to be defined within this function, one should call the `Module`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.

</Tip>







Example:

```python
>>> from transformers import TransfoXLTokenizer, TFTransfoXLLMHeadModel
>>> import tensorflow as tf

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TFTransfoXLLMHeadModel.from_pretrained("transfo-xl-wt103")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
>>> outputs = model(inputs)
>>> logits = outputs.logits
```


</div></div>

<h2 id="transformers.TFTransfoXLForSequenceClassification">TFTransfoXLForSequenceClassification</h2>

<div class="docstring">

<docstring><name>class transformers.TFTransfoXLForSequenceClassification</name><anchor>transformers.TFTransfoXLForSequenceClassification</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L1086</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **config** ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) -- 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 [from_pretrained()](/docs/transformers/pr_15592/en/main_classes/model#transformers.PreTrainedModel.from_pretrained) method to load the model weights.</paramsdesc><paramgroups>0</paramgroups></docstring>

The Transfo XL Model transformer with a sequence classification head on top (linear layer).

[TFTransfoXLForSequenceClassification](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TFTransfoXLForSequenceClassification) uses the last token in order to do the classification, as other causal
models (e.g. GPT-1,GPT-2) do.

Since it does classification on the last token, it requires to know the position of the last token. If a
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
each row of the batch).


This model inherits from [TFPreTrainedModel](/docs/transformers/pr_15592/en/main_classes/model#transformers.TFPreTrainedModel). Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)

This model is also a [tf.keras.Model](https://www.tensorflow.org/api_docs/python/tf/keras/Model) subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.

<Tip>

TF 2.0 models accepts two formats as inputs:

- having all inputs as keyword arguments (like PyTorch models), or
- having all inputs as a list, tuple or dict in the first positional arguments.

This second option is useful when using `tf.keras.Model.fit` method which currently requires having all the
tensors in the first argument of the model call function: `model(inputs)`.

If you choose this second option, there are three possibilities you can use to gather all the input Tensors in the
first positional argument :

- a single Tensor with `input_ids` only and nothing else: `model(inputs_ids)`
- a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
`model([input_ids, attention_mask])` or `model([input_ids, attention_mask, token_type_ids])`
- a dictionary with one or several input Tensors associated to the input names given in the docstring:
`model(&amp;lcub;"input_ids": input_ids, "token_type_ids": token_type_ids})`

</Tip>





<div class="docstring">
<docstring><name>call</name><anchor>transformers.TFTransfoXLForSequenceClassification.call</anchor><source>https://github.com/huggingface/transformers/blob/pr_15592/src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py#L1101</source><parameters>[{"name": "input_ids", "val": " = None"}, {"name": "mems", "val": " = None"}, {"name": "head_mask", "val": " = None"}, {"name": "inputs_embeds", "val": " = None"}, {"name": "output_attentions", "val": " = None"}, {"name": "output_hidden_states", "val": " = None"}, {"name": "return_dict", "val": " = None"}, {"name": "labels", "val": " = None"}, {"name": "training", "val": " = False"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **input_ids** (`tf.Tensor` or `Numpy array` of shape `(batch_size, sequence_length)`) --
  Indices of input sequence tokens in the vocabulary.

  Indices can be obtained using [BertTokenizer](/docs/transformers/pr_15592/en/model_doc/bert#transformers.BertTokenizer). See [PreTrainedTokenizer.__call__()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) and
  [PreTrainedTokenizer.encode()](/docs/transformers/pr_15592/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) for details.

  [What are input IDs?](../glossary#input-ids)
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) --
  Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
  `mems` output below). Can be used to speed up sequential decoding. The token ids which have their mems
  given to this model should not be passed as `input_ids` as they have already been computed.
- **head_mask** (`tf.Tensor` or `Numpy array` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*) --
  Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

  - 1 indicates the head is **not masked**,
  - 0 indicates the head is **masked**.
- **inputs_embeds** (`tf.Tensor` or `Numpy array` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) --
  Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
  is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
  model's internal embedding lookup matrix.
- **output_attentions** (`bool`, *optional*) --
  Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
  tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
  config will be used instead.
- **output_hidden_states** (`bool`, *optional*) --
  Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
  more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
  used instead.
- **return_dict** (`bool`, *optional*) --
  Whether or not to return a [ModelOutput](/docs/transformers/pr_15592/en/main_classes/output#transformers.file_utils.ModelOutput) instead of a plain tuple. This argument can be used
  in eager mode, in graph mode the value will always be set to True.
- **training** (`bool`, *optional*, defaults to `False`) --
  Whether or not to use the model in training mode (some modules like dropout modules have different
  behaviors between training and evaluation).

- **labels** (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*) --
  Labels for computing the cross entropy classification loss. Indices should be in `[0, ...,
  config.vocab_size - 1]`.</paramsdesc><paramgroups>0</paramgroups><rettype>`transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLSequenceClassifierOutputWithPast`or `tuple(tf.Tensor)`</rettype><retdesc>A `transformers.models.transfo_xl.modeling_tf_transfo_xl.TFTransfoXLSequenceClassifierOutputWithPast`or a tuple of `tf.Tensor` (if
`return_dict=False` is passed or when `config.return_dict=False`) comprising various elements depending on the
configuration ([TransfoXLConfig](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TransfoXLConfig)) and inputs.

- **loss** (`tf.Tensor` of shape `(1,)`, *optional*, returned when `labels` is provided) -- Classification (or regression if config.num_labels==1) loss.
- **logits** (`tf.Tensor` of shape `(batch_size, config.num_labels)`) -- Classification (or regression if config.num_labels==1) scores (before SoftMax).
- **mems** (`List[tf.Tensor]` of length `config.n_layers`) -- Contains pre-computed hidden-states (key and values in the attention blocks). Can be used (see `mems`
  input) to speed up sequential decoding. The token ids which have their past given to this model should not
  be passed as input ids as they have already been computed.
- **hidden_states** (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`) -- Tuple of `tf.Tensor` (one for the output of the embeddings + one for the output of each layer) of shape
  `(batch_size, sequence_length, hidden_size)`.

  Hidden-states of the model at the output of each layer plus the initial embedding outputs.
- **attentions** (`tuple(tf.Tensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`) -- Tuple of `tf.Tensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
  sequence_length)`.

  Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
  heads.</retdesc></docstring>
The [TFTransfoXLForSequenceClassification](/docs/transformers/pr_15592/en/model_doc/transfo-xl#transformers.TFTransfoXLForSequenceClassification) forward method, overrides the `__call__` special method.

<Tip>

Although the recipe for forward pass needs to be defined within this function, one should call the `Module`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.

</Tip>







Example:

```python
>>> from transformers import TransfoXLTokenizer, TFTransfoXLForSequenceClassification
>>> import tensorflow as tf

>>> tokenizer = TransfoXLTokenizer.from_pretrained("transfo-xl-wt103")
>>> model = TFTransfoXLForSequenceClassification.from_pretrained("transfo-xl-wt103")

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="tf")
>>> inputs["labels"] = tf.reshape(tf.constant(1), (-1, 1))  # Batch size 1

>>> outputs = model(inputs)
>>> loss = outputs.loss
>>> logits = outputs.logits
```


</div></div>

<h2 id="transformers.AdaptiveEmbedding">Internal Layers</h2>

<div class="docstring">
</div>

<div class="docstring">
</div>
