class_docstr: T5 encoder as a separate model which fuse multi-modal input.
  
  This module contains the encoder part of a pretrained T5. It is useful when
  adopting the pretrained T5 encoder as a part of a larger network. Note that
  the embedding layer should be created outside the module and provided as a
  parameter `shared_embedding` to share it in other parts of the network (e.g.,
  text encoder). If `shared_embedding` is not provided, the embedding layer is
  created within the module.
  
  Attributes:
    vocab_size: Size of the vocabulary.
    emb_dim: Size of the embeddings.
    num_heads: Number of attention heads.
    num_encoder_layers: Number of encoder layers.
    num_decoder_layers: Number of decoder layers.
    head_dim: Size of the embeddings in each head.
    mlp_dim: Size of the MLP output embeddings.
    dropout_rate: Dropout rate.
    dtype: Data type.
    mlp_activations: Sequence of activations in MLP.
    logits_via_embedding: Use the embedding weights for computing logits.
docstr: Function to fuse text and imaget embedding.
  
  encode both the encoded text embedding (encoder_input_embs) and
  encoded image embedding (fused_input_embs) together using
  self-attentive Transformer.
  
  Args:
    fused_input_embs: pre-encoded embeddings of other modalities
    encoder_input_embs: encoded text embedding sequence
    encoder_mask: mask for encoding part
    fused_mask: mask for fusion part
    att_mask: pre-computed attention product to each layer's output
    use_dropout: whether to use dropout.
    output: whether it's output layer.
  
  Returns:
    Sequence of token embedding after fusion
code: def __call__(
      self,
      fused_input_embs,
      encoder_input_embs=None,
      encoder_mask=None,
      fused_mask=None,
      att_mask=None,
      use_dropout=True,
      output=False,
  ):
      """Function to fuse text and imaget embedding.
  
      encode both the encoded text embedding (encoder_input_embs) and
      encoded image embedding (fused_input_embs) together using
      self-attentive Transformer.
  
      Args:
        fused_input_embs: pre-encoded embeddings of other modalities
        encoder_input_embs: encoded text embedding sequence
        encoder_mask: mask for encoding part
        fused_mask: mask for fusion part
        att_mask: pre-computed attention product to each layer's output
        use_dropout: whether to use dropout.
        output: whether it's output layer.
  
      Returns:
        Sequence of token embedding after fusion
      """
      cfg = self.t5_config
      if encoder_input_embs is not None:
          x = jnp.concatenate(
              [encoder_input_embs, fused_input_embs], axis=1
          )
      else:
          x = fused_input_embs
      rel_emb = t5_layers.RelativePositionBiases(
          num_buckets=32,
          max_distance=128,
          num_heads=self.t5_config.num_heads,
          dtype=self.t5_config.dtype,
          embedding_init=nn.initializers.variance_scaling(
              1.0, "fan_avg", "uniform"
          ),
      )
  
      if encoder_mask is not None:
          if fused_mask is None:
              pad_width = fused_input_embs.shape[1]
              fused_mask = jnp.pad(
                  array=encoder_mask,
                  pad_width=((0, 0), (0, pad_width)),
                  mode="constant",
                  constant_values=1.0,
              )
          else:
              fused_mask = jnp.concatenate(
                  [encoder_mask, fused_mask], axis=1
              )
  
      mask_matrix = t5_layers.make_attention_mask(
          fused_mask, fused_mask, dtype=cfg.dtype
      )
      attn_weights_all_layers = []
      for _ in range(
          cfg.num_encoder_layers - self.num_fusion_layers,
          cfg.num_encoder_layers,
      ):
          # [batch, length, emb_dim] -> [batch, length, emb_dim]
          x, attn_weights = FusionEncoderLayer(
              config=cfg, relative_embedding=rel_emb
          )(
              x,
              encoder_mask=mask_matrix,
              att_mask=att_mask,
              deterministic=not use_dropout,
          )
          attn_weights_all_layers += [attn_weights]
      if output:
          x = t5_layers.LayerNorm(dtype=cfg.dtype)(x)
      if att_mask is not None:
          x = x * att_mask
      x = nn.Dropout(rate=cfg.dropout_rate)(
          x, deterministic=not use_dropout
      )
      return x, fused_mask, attn_weights_all_layers
  
imports: import functools
  from typing import Optional, Sequence
  from flax import linen
  import jax
  import jax.numpy
  from scenic.projects.knowledge_visual_language.models import constants
  from t5x.examples.t5 import layers
  from t5x.examples.t5 import network
label_desc: Use image node_id 2 for calling the FusedT5Encoder obj's underlying member method code with example usage: obj.__call__(fused_input_embs, encoder_input_embs, encoder_mask, fused_mask, att_mask, use_dropout, output) and returns: x,  fused_mask,  attn_weights_all_layers