code: def __init__(
      self,
      config: Optional[PretrainedConfig] = None,
      question_encoder: Optional[PreTrainedModel] = None,
      generator: Optional[PreTrainedModel] = None,
      retriever: Optional[RagRetriever] = None,
      **kwargs,
  ):
      assert config is not None or (
          question_encoder is not None and generator is not None
      ), "Either a configuration or an 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
          )
  
      super().__init__(config)
  
      # instantiate model
      self.rag = RagModel(
          config=config,
          question_encoder=question_encoder,
          generator=generator,
          retriever=retriever,
      )
  
imports: import copy
  from dataclasses import dataclass
  from typing import Callable, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from ...configuration_utils import PretrainedConfig
  from ...generation import BeamSearchScorer, GenerationConfig, LogitsProcessorList, StoppingCriteriaList
  from ...modeling_outputs import ModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import 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 RagTokenForGeneration object from inherited base classes: RagPreTrainedModel with example: obj = RagTokenForGeneration(config, question_encoder, generator, retriever)