class_docstr: Modification of FID (https://arxiv.org/pdf/2007.01282.pdf) model.
  
  Take continous embedding of retrieved document at middle fusion layer
  instead of whole sequence at input.
class_docstr_tok: ["Modification","of","FID","(","https",":","\/\/arxiv.org\/pdf\/2007.01282.pdf",")","model",".","Take","continous","embedding","of","retrieved","document","at","middle","fusion","layer","instead","of","whole","sequence","at","input","."]
code: def encode_knowledge(
      self,
      retr_texts,
      retr_images=None,
      bsz=None,
      train=False,
      random_drop_image=False,
      frozen_base=True,
  ):
      retr_tokens, retr_masks, retr_img_emb = self.get_base_encoded(
          bsz=bsz,
          image=retr_images,
          text_tokens=retr_texts,
          train=train,
          random_drop_image=random_drop_image,
          frozen_base=frozen_base,
      )
      retr_tokens = jnp.concatenate(retr_tokens, axis=1)  # B×(I+N)×d
      retr_keys = self.key_head(
          encoded_emb=retr_tokens,
          encoder_mask=retr_masks,
          use_dropout=train,
      )  # B×(I+N)×d -> B×d
      (
          compressed_val,
          compressed_mask,
          disentangle_reg,
      ) = self.value_perceiver(
          encoded=retr_tokens,
          encoded_mask=retr_masks,
          use_dropout=train,
      )
  
      return (
          retr_keys,
          compressed_val,
          compressed_mask,
          retr_img_emb,
          disentangle_reg,
      )
  
imports: from typing import Any, Dict, Optional
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  from scenic.model_lib.base_models import base_model
  from scenic.projects.knowledge_visual_language.models import constants
  from scenic.projects.knowledge_visual_language.models import layers
  from scenic.projects.knowledge_visual_language.models import losses
  from scenic.projects.knowledge_visual_language.models import metrics
  from scenic.projects.knowledge_visual_language.models import vit
  from scenic.projects.t5 import layers
  from scenic.projects.t5 import model
label_desc: Use image node_id 4 for calling the FusionInDecoderSoftModule obj's underlying member method code with example usage: obj.encode_knowledge(retr_texts, retr_images, bsz, train, random_drop_image, frozen_base) and returns: retr_keys,  compressed_val,  compressed_mask,  retr_img_emb,  disentangle_reg