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.
    shared_embedding: Optional. Embedding layer that is shared outside this
      module. If not given, a non-shared embedding layer will be created within
      the module.
docstr: encode the text sentence only.
  
  Args:
    encoder_input_tokens: input text tokens
    encoder_segment_ids: segmend ID in packing mode
    use_dropout: whether to use dropout during Training
    frozen_base: whether froze the text encoder
  
  Returns:
    Sequence of token embedding with or without fusion
code: def __call__(
      self,
      encoder_input_tokens,
      encoder_segment_ids=None,
      use_dropout=True,
      frozen_base=True,
  ):
      """encode the text sentence only.
  
      Args:
        encoder_input_tokens: input text tokens
        encoder_segment_ids: segmend ID in packing mode
        use_dropout: whether to use dropout during Training
        frozen_base: whether froze the text encoder
  
      Returns:
        Sequence of token embedding with or without fusion
      """
      cfg = self.t5_config
      assert encoder_input_tokens.ndim == 2  # (batch, len)
      # Make padding attention mask.
      encoder_mask = encoder_input_tokens > 0
      mask_matrix = t5_layers.make_attention_mask(
          encoder_input_tokens > 0,
          encoder_input_tokens > 0,
          dtype=cfg.dtype,
      )
      # Add segmentation block-diagonal attention mask if using segmented data.
      if encoder_segment_ids is not None:
          mask_matrix = t5_layers.combine_masks(
              mask_matrix,
              t5_layers.make_attention_mask(
                  encoder_segment_ids,
                  encoder_segment_ids,
                  jnp.equal,
                  dtype=cfg.dtype,
              ),
          )
  
      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"
          ),
      )
  
      # [batch, length] -> [batch, length, emb_dim]
      x = self.shared_embedding(encoder_input_tokens.astype("int32"))
      x = nn.Dropout(rate=cfg.dropout_rate, broadcast_dims=(-2,))(
          x, deterministic=not use_dropout
      )
      x = x.astype(cfg.dtype)
      n_layer = cfg.num_encoder_layers - self.num_fusion_layers
      frozen_layer_id = int(n_layer * 0.8) - 1
      for lyr in range(n_layer):
          # [batch, length, emb_dim] -> [batch, length, emb_dim]
          x = t5_network.EncoderLayer(
              config=cfg, relative_embedding=rel_emb
          )(x, mask_matrix, deterministic=not use_dropout)
          if frozen_base and lyr == frozen_layer_id:
              x = jax.lax.stop_gradient(x)
      return x, encoder_mask
  
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 LowerT5Encoder obj's underlying member method code with example usage: obj.__call__(encoder_input_tokens, encoder_segment_ids, use_dropout, frozen_base) and returns: x,  encoder_mask