class_docstr: T5 text encoder.
class_docstr_tok: ["T5","text","encoder","."]
code: def __call__(
      self,
      text: jnp.ndarray,
      mask: Optional[jnp.ndarray] = None,
      *,
      train: bool = False,
      debug: bool = False,
  ) -> jnp.ndarray:
      # We leave the default eps because the LayerNorm is always computed in FP32.
      t5 = t5_1_1.encoder_decoder(
          **dataclasses.asdict(CONFIGS[self.config_name]),
          dtype=self.dtype,
      )
      # TODO(sacastro): normalize?
  
      # T5 computes its own mask. So we don't pass it.
      encoded_tokens = t5.encode(text, enable_dropout=train)
  
      if self.return_all_tokens:
          return encoded_tokens
      else:
          if mask is None:
              mask = text > 0
  
          # We average the token embeddings. In Sentence-T5
          # (https://arxiv.org/abs/2108.08877), they show the mean works great.
          num_tokens = mask.sum(axis=-1, keepdims=True)
          num_tokens = jnp.maximum(
              num_tokens, jnp.ones_like(num_tokens)
          )
          return (encoded_tokens * mask[..., jnp.newaxis]).sum(
              axis=-2
          ) / num_tokens
  
file_path: scenic/scenic/projects/lang4video/model/t5.py
imports: import dataclasses
  from typing import Optional
  import flax
  from flax.core.frozen_dict import FrozenDict
  import flax.linen
  import jax
  import jax.numpy
  from scenic.projects.lang4video.model.base_encoders import TextEncoder
  from t5x import checkpoints
  from flaxformer.architectures.t5 import t5_1_1
label_desc: Use image node_id 1 for calling the T5TextEncoder obj's underlying member method code with example usage: obj.__call__(text, mask) and returns: encoded_tokens, unknown