code: def __init__(
      self,
      config: Optional[PretrainedConfig] = None,
      question_encoder: Optional[TFPreTrainedModel] = None,
      generator: Optional[TFPreTrainedModel] = None,
      retriever: Optional[RagRetriever] = None,
      load_weight_prefix: Optional[str] = None,
      **kwargs,
  ):
      assert config is not None or (
          question_encoder is not None and generator is not None
      ), "Either a configuration or an question_encoder and a generator has to be provided."
  
      if config is None:
          config = RagConfig.from_question_encoder_generator_configs(
              question_encoder.config, generator.config, **kwargs
          )
      else:
          assert isinstance(
              config, self.config_class
          ), f"config: {config} has to be of type {self.config_class}"
      super().__init__(config, **kwargs)
  
      if question_encoder is None:
          from ..auto.modeling_tf_auto import TFAutoModel
  
          question_encoder = TFAutoModel.from_config(
              config.question_encoder, name="question_encoder"
          )
  
      if generator is None:
          from ..auto.modeling_tf_auto import TFAutoModelForSeq2SeqLM
  
          load_weight_prefix = (
              load_weight_prefix
              if load_weight_prefix is not None
              else self.load_weight_prefix
          )
          generator = TFAutoModelForSeq2SeqLM.from_config(
              config.generator,
              name="generator",
              load_weight_prefix=load_weight_prefix + "/generator",
          )
  
      self.retriever = retriever
      if self.retriever is not None:
          assert isinstance(
              retriever, RagRetriever
          ), f"`self.retriever` is of type {type(self.retriever)}, but should be of type `RagRetriever`"
          self.retriever = retriever
  
      self.question_encoder = question_encoder
      self.generator = generator
  
imports: from __future__ import annotations
  import copy
  from dataclasses import dataclass
  from typing import List, Optional, Tuple, Union
  import numpy
  import tensorflow
  from ...configuration_utils import PretrainedConfig
  from ...generation import TFLogitsProcessorList
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFModelInputType, TFPreTrainedModel, shape_list, unpack_inputs
  from ...utils import ModelOutput, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_rag import RagConfig
  from .retrieval_rag import RagRetriever
label_desc: Use image node_id 1 to create a new TFRagModel object from inherited base classes: TFRagPreTrainedModel with example: obj = TFRagModel(config, question_encoder, generator, retriever, load_weight_prefix)