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_image(self, image, train=False):
      _, out = self.img_encoder(image, train=train)  # B×W×H×3 -> B×N×d
      img_query = jnp.asarray(out["logits_2d"] * 4, self.dtype)
      n_img_tokens = img_query.shape[1] * img_query.shape[2]
      img_query = jnp.reshape(img_query, [-1, n_img_tokens, self.ndim])
      img_emb = jnp.asarray(out["head_input"], self.dtype)
      return img_query, img_emb
  
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 7 for calling the FusionInDecoderSoftModule obj's underlying member method code with example usage: obj.encode_image(image, train) and returns: img_query,  img_emb