class_docstr: FID model (https://arxiv.org/pdf/2007.01282.pdf) with a retrieval module over a knowledge memory.
class_docstr_tok: ["FID","model","(","https",":","\/\/arxiv.org\/pdf\/2007.01282.pdf",")","with","a","retrieval","module","over","a","knowledge","memory","."]
docstr: wraps _t5_decoder call (no packing) to enable autoregressive decoding.
docstr_tok: ["wraps","_t5_decoder","call","(","no","packing",")","to","enable","autoregressive","decoding","."]
code: def t5_decode(
      self,
      encoded,
      encoder_input_tokens: jnp.ndarray,  # Only needed for masks.
      decoder_input_tokens: jnp.ndarray,
      decoder_target_tokens: jnp.ndarray,
      enable_dropout: bool = True,
      decode: bool = False,
      max_decode_length: Optional[int] = None,
  ):
      """wraps _t5_decoder call (no packing) to enable autoregressive decoding."""
      # Without this wrapper flax.model.apply does not know self._t5_decoder yet
      # when doing a single (autoregressive) decode step.
      return self.out_decoder(
          encoded=encoded,
          encoder_input_tokens=encoder_input_tokens,
          decoder_input_tokens=decoder_input_tokens,
          decoder_target_tokens=decoder_target_tokens,
          enable_dropout=enable_dropout,
          decode=decode,
          max_decode_length=max_decode_length,
      )
  
imports: import functools
  from typing import Any, Dict, Mapping, Optional, Tuple, List
  from absl import logging
  import flax.linen
  import jax
  from jax.experimental import host_callback
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.dataset_lib import dataset_utils
  from scenic.model_lib.base_models import base_model
  from scenic.projects.knowledge_visual_language.data import data_utils
  from scenic.projects.knowledge_visual_language.models import constants
  from scenic.projects.knowledge_visual_language.models import fusion_in_decoder_soft
  from scenic.projects.knowledge_visual_language.models import layers
  from scenic.projects.knowledge_visual_language.models import local_memory
  from scenic.projects.knowledge_visual_language.models import losses
  from scenic.projects.knowledge_visual_language.models import metrics
  from t5x import decoding
label_desc: Use image node_id 5 for calling the KnowledgeFIDModule obj's underlying member method code with example usage: obj.t5_decode(encoded, encoder_input_tokens, decoder_input_tokens, decoder_target_tokens, enable_dropout, decode, max_decode_length) and returns: self