class_docstr: [`TFEncoderDecoderModel`] is a generic model class that will be instantiated as a transformer architecture with one
  of the base model classes of the library as encoder and another one as decoder when created with the
  [`~TFAutoModel.from_pretrained`] class method for the encoder and [`~TFAutoModelForCausalLM.from_pretrained`] class
  method for the decoder.
class_docstr_tok: ["[","`","TFEncoderDecoderModel","`","]","is","a","generic","model","class","that","will","be","instantiated","as","a","transformer","architecture","with","one","of","the","base","model","classes","of","the","library","as","encoder","and","another","one","as","decoder","when","created","with","the","[","`","~TFAutoModel.from_pretrained","`","]","class","method","for","the","encoder","and","[","`","~TFAutoModelForCausalLM.from_pretrained","`","]","class","method","for","the","decoder","."]
docstr: Example:
  
  ```python
  >>> from transformers import TFEncoderDecoderModel
  
  >>> model = TFEncoderDecoderModel.from_pretrained("ydshieh/bert2bert-cnn_dailymail-fp16")
  ```
docstr_tok: ["Example",":","``","`","python",">",">",">","from","transformers","import","TFEncoderDecoderModel",">",">",">","model","=","TFEncoderDecoderModel.from_pretrained","(","``","ydshieh\/bert2bert-cnn_dailymail-fp16","''",")","``","`"]
code: def from_pretrained(
      cls, pretrained_model_name_or_path, *model_args, **kwargs
  ):
      r"""
      Example:
  
      ```python
      >>> from transformers import TFEncoderDecoderModel
  
      >>> model = TFEncoderDecoderModel.from_pretrained("ydshieh/bert2bert-cnn_dailymail-fp16")
      ```"""
  
      from_pt = kwargs.pop("from_pt", False)
      if from_pt:
          import torch
  
          from transformers import EncoderDecoderModel
  
          # a workaround to load from pytorch checkpoint
          _model = EncoderDecoderModel.from_pretrained(
              pretrained_model_name_or_path, *model_args, **kwargs
          )
          config = _model.config
  
          with tempfile.TemporaryDirectory() as tmpdirname:
              encoder_dir = os.path.join(tmpdirname, "encoder")
              decoder_dir = os.path.join(tmpdirname, "decoder")
              _model.encoder.save_pretrained(encoder_dir)
              _model.decoder.save_pretrained(decoder_dir)
  
              if hasattr(_model, "enc_to_dec_proj"):
                  enc_to_dec_proj_kernel = tf.transpose(
                      tf.constant(
                          _model.enc_to_dec_proj.weight.detach()
                          .to("cpu")
                          .numpy()
                      ),
                      perm=(1, 0),
                  )
                  enc_to_dec_proj_bias = tf.constant(
                      _model.enc_to_dec_proj.bias.detach()
                      .to("cpu")
                      .numpy()
                  )
  
              del _model
              gc.collect()
              torch.cuda.empty_cache()
  
              model = (
                  TFEncoderDecoderModel.from_encoder_decoder_pretrained(
                      encoder_dir,
                      decoder_dir,
                      encoder_from_pt=True,
                      decoder_from_pt=True,
                  )
              )
              # This is only for copying some specific attributes of this particular model.
              model.config = config
  
              if hasattr(model, "enc_to_dec_proj"):
                  model(model.dummy_inputs)
                  model.enc_to_dec_proj.kernel.assign(
                      enc_to_dec_proj_kernel
                  )
                  model.enc_to_dec_proj.bias.assign(
                      enc_to_dec_proj_bias
                  )
  
              return model
  
      return super().from_pretrained(
          pretrained_model_name_or_path, *model_args, **kwargs
      )
  
imports: import gc
  import os
  import tempfile
  import warnings
  from typing import Optional
  import tensorflow
  from ...configuration_utils import PretrainedConfig
  from ...modeling_tf_outputs import TFBaseModelOutput, TFSeq2SeqLMOutput
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFPreTrainedModel, get_initializer, unpack_inputs
  from ...tf_utils import shape_list
  from ...utils import DUMMY_INPUTS, ModelOutput, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from ..auto.configuration_auto import AutoConfig
  from ..auto.modeling_tf_auto import TFAutoModel, TFAutoModelForCausalLM
  from .configuration_encoder_decoder import EncoderDecoderConfig
label_desc: Use image node_id 8 for calling the TFEncoderDecoderModel obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrained_model_name_or_path) and returns: super, model