docstr: mc_token_ids (`tf.Tensor` or `Numpy array` of shape `(batch_size, num_choices)`, *optional*, default to index of the last token of the input):
      Index of the classification token in each input sequence. Selected in the range `[0, input_ids.size(-1) -
      1]`.
  
  Return:
  
  Examples:
  
  ```python
  >>> import tensorflow as tf
  >>> from transformers import GPT2Tokenizer, TFGPT2DoubleHeadsModel
  
  >>> tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
  >>> model = TFGPT2DoubleHeadsModel.from_pretrained("gpt2")
  
  >>> # Add a [CLS] to the vocabulary (we should train it also!)
  >>> num_added_tokens = tokenizer.add_special_tokens({"cls_token": "[CLS]"})
  
  >>> embedding_layer = model.resize_token_embeddings(
  ...     len(tokenizer)
  ... )  # Update the model embeddings with the new vocabulary size
  
  >>> choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
  >>> encoded_choices = [tokenizer.encode(s) for s in choices]
  >>> cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]
  
  >>> input_ids = tf.constant(encoded_choices)[None, :]  # Batch size: 1, number of choices: 2
  >>> mc_token_ids = tf.constant([cls_token_location])  # Batch size: 1
  
  >>> outputs = model(input_ids, mc_token_ids=mc_token_ids)
  >>> lm_prediction_scores, mc_prediction_scores = outputs[:2]
  ```
docstr_tok: ["mc_token_ids","(","`","tf.Tensor","`","or","`","Numpy","array","`","of","shape","`","(","batch_size",",","num_choices",")","`",",","*","optional","*",",","default","to","index","of","the","last","token","of","the","input",")",":","Index","of","the","classification","token","in","each","input","sequence",".","Selected","in","the","range","`","[","0",",","input_ids.size","(","-1",")","-","1","]","`",".","Return",":","Examples",":","``","`","python",">",">",">","import","tensorflow","as","tf",">",">",">","from","transformers","import","GPT2Tokenizer",",","TFGPT2DoubleHeadsModel",">",">",">","tokenizer","=","GPT2Tokenizer.from_pretrained","(","``","gpt2","''",")",">",">",">","model","=","TFGPT2DoubleHeadsModel.from_pretrained","(","``","gpt2","''",")",">",">",">","#","Add","a","[","CLS","]","to","the","vocabulary","(","we","should","train","it","also","!",")",">",">",">","num_added_tokens","=","tokenizer.add_special_tokens","(","{","``","cls_token","''",":","``","[","CLS","]","''","}",")",">",">",">","embedding_layer","=","model.resize_token_embeddings","(","...","len","(","tokenizer",")","...",")","#","Update","the","model","embeddings","with","the","new","vocabulary","size",">",">",">","choices","=","[","``","Hello",",","my","dog","is","cute","[","CLS","]","''",",","``","Hello",",","my","cat","is","cute","[","CLS","]","''","]",">",">",">","encoded_choices","=","[","tokenizer.encode","(","s",")","for","s","in","choices","]",">",">",">","cls_token_location","=","[","tokens.index","(","tokenizer.cls_token_id",")","for","tokens","in","encoded_choices","]",">",">",">","input_ids","=","tf.constant","(","encoded_choices",")","[","None",",",":","]","#","Batch","size",":","1",",","number","of","choices",":","2",">",">",">","mc_token_ids","=","tf.constant","(","[","cls_token_location","]",")","#","Batch","size",":","1",">",">",">","outputs","=","model","(","input_ids",",","mc_token_ids=mc_token_ids",")",">",">",">","lm_prediction_scores",",","mc_prediction_scores","=","outputs","[",":2","]","``","`"]
code: def call(
      self,
      input_ids: Optional[TFModelInputType] = None,
      past_key_values: Optional[
          Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]
      ] = None,
      attention_mask: Optional[Union[np.ndarray, tf.Tensor]] = None,
      token_type_ids: Optional[Union[np.ndarray, tf.Tensor]] = None,
      position_ids: Optional[Union[np.ndarray, tf.Tensor]] = None,
      head_mask: Optional[Union[np.ndarray, tf.Tensor]] = None,
      inputs_embeds: Optional[Union[np.ndarray, tf.Tensor]] = None,
      mc_token_ids: Optional[Union[np.ndarray, tf.Tensor]] = None,
      use_cache: Optional[bool] = None,
      output_attentions: Optional[bool] = None,
      output_hidden_states: Optional[bool] = None,
      return_dict: Optional[bool] = None,
      training: Optional[bool] = False,
  ) -> Union[TFGPT2DoubleHeadsModelOutput, Tuple[tf.Tensor]]:
      r"""
      mc_token_ids (`tf.Tensor` or `Numpy array` of shape `(batch_size, num_choices)`, *optional*, default to index of the last token of the input):
          Index of the classification token in each input sequence. Selected in the range `[0, input_ids.size(-1) -
          1]`.
  
      Return:
  
      Examples:
  
      ```python
      >>> import tensorflow as tf
      >>> from transformers import GPT2Tokenizer, TFGPT2DoubleHeadsModel
  
      >>> tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
      >>> model = TFGPT2DoubleHeadsModel.from_pretrained("gpt2")
  
      >>> # Add a [CLS] to the vocabulary (we should train it also!)
      >>> num_added_tokens = tokenizer.add_special_tokens({"cls_token": "[CLS]"})
  
      >>> embedding_layer = model.resize_token_embeddings(
      ...     len(tokenizer)
      ... )  # Update the model embeddings with the new vocabulary size
  
      >>> choices = ["Hello, my dog is cute [CLS]", "Hello, my cat is cute [CLS]"]
      >>> encoded_choices = [tokenizer.encode(s) for s in choices]
      >>> cls_token_location = [tokens.index(tokenizer.cls_token_id) for tokens in encoded_choices]
  
      >>> input_ids = tf.constant(encoded_choices)[None, :]  # Batch size: 1, number of choices: 2
      >>> mc_token_ids = tf.constant([cls_token_location])  # Batch size: 1
  
      >>> outputs = model(input_ids, mc_token_ids=mc_token_ids)
      >>> lm_prediction_scores, mc_prediction_scores = outputs[:2]
      ```"""
  
      if input_ids is not None:
          input_shapes = shape_list(input_ids)
      else:
          input_shapes = shape_list(inputs_embeds)[:-1]
  
      seq_length = input_shapes[-1]
      flat_input_ids = (
          tf.reshape(input_ids, (-1, seq_length))
          if input_ids is not None
          else None
      )
      flat_attention_mask = (
          tf.reshape(attention_mask, (-1, seq_length))
          if attention_mask is not None
          else None
      )
      flat_token_type_ids = (
          tf.reshape(token_type_ids, (-1, seq_length))
          if token_type_ids is not None
          else None
      )
      flat_position_ids = (
          tf.reshape(position_ids, (-1, seq_length))
          if position_ids is not None
          else None
      )
      transformer_outputs = self.transformer(
          input_ids=flat_input_ids,
          past_key_values=past_key_values,
          attention_mask=flat_attention_mask,
          token_type_ids=flat_token_type_ids,
          position_ids=flat_position_ids,
          head_mask=head_mask,
          inputs_embeds=inputs_embeds,
          encoder_hidden_states=None,
          encoder_attention_mask=None,
          use_cache=use_cache,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
          training=training,
      )
      hidden_states = transformer_outputs[0]
      hidden_states = tf.reshape(
          hidden_states, input_shapes + shape_list(hidden_states)[-1:]
      )
      lm_logits = self.transformer.wte(hidden_states, mode="linear")
      mc_logits = self.multiple_choice_head(
          hidden_states, mc_token_ids, training=training
      )
      mc_logits = tf.squeeze(mc_logits, axis=-1)
  
      if not return_dict:
          return (lm_logits, mc_logits) + transformer_outputs[1:]
  
      return TFGPT2DoubleHeadsModelOutput(
          logits=lm_logits,
          mc_logits=mc_logits,
          past_key_values=transformer_outputs.past_key_values,
          hidden_states=transformer_outputs.hidden_states,
          attentions=transformer_outputs.attentions,
      )
  
imports: from dataclasses import dataclass
  from typing import List, Optional, Tuple, Union
  import numpy
  import tensorflow
  from ...activations_tf import get_tf_activation
  from ...modeling_tf_outputs import TFBaseModelOutputWithPastAndCrossAttentions, TFCausalLMOutputWithCrossAttentions, TFSequenceClassifierOutputWithPast
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFConv1D, TFModelInputType, TFPreTrainedModel, TFSequenceClassificationLoss, TFSequenceSummary, TFSharedEmbeddings, get_initializer, keras_serializable, unpack_inputs
  from ...tf_utils import shape_list, stable_softmax
  from ...utils import DUMMY_INPUTS, ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_gpt2 import GPT2Config
label_desc: Use image node_id 2 for calling the TFGPT2DoubleHeadsModel obj's underlying member method code with example usage: obj.call(input_ids, past_key_values, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, mc_token_ids, use_cache, output_attentions, output_hidden_states, return_dict, training) and returns: TFGPT2DoubleHeadsModelOutput, unknown