class_docstr: Implements a video+text single-tower backbone.
  
  Attributes:
    num_classes: Number of output classes.
    video_tower_config: The config of the video tower.
    text_tower_config: The config of the text tower.
    video_text_fusion_config: The config of video+text fusion.
    classifier: 'gap' or 'token'
class_docstr_tok: ["Implements","a","video+text","single-tower","backbone",".","Attributes",":","num_classes",":","Number","of","output","classes",".","video_tower_config",":","The","config","of","the","video","tower",".","text_tower_config",":","The","config","of","the","text","tower",".","video_text_fusion_config",":","The","config","of","video+text","fusion",".","classifier",":","'gap","'","or","'token","'"]
docstr: Encodes text.
docstr_tok: ["Encodes","text","."]
code: def encode_text(
      self,
      inputs: Dict[str, Any],
      task: str,
      train: bool = False,
      debug: bool = False,
  ) -> Optional[jnp.ndarray]:
      """Encodes text."""
  
      if self.text_tower_config is None:
          return None
  
      if task == "moment_retrieval":
          # Merges all captions
          text_inputs = jax.tree_util.tree_map(
              lambda x: x.reshape((-1, x.shape[-1])), inputs["caption"]
          )
      elif task == "highlight_detection":
          input_key = self.text_tower_config.get(
              "input_key", "video_title"
          )
          text_inputs = inputs[input_key]
      else:
          # The class names are the same in all batches.
          text_inputs = jax.tree_util.tree_map(
              lambda x: x[0], inputs["class_names"]
          )
      text_tokens = self.text_encoder(
          text_inputs, train=train, debug=debug
      )
      if self.text_tower_config.get("freeze", False):
          text_tokens = jax.lax.stop_gradient(text_tokens)
      if self.text_tower_config.get("projection_size") is not None:
          text_tokens = self.text_projection(text_tokens)
      return text_tokens
  
imports: from typing import Any, Dict, Optional
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  from scenic.projects.unloc import action_segmentation_base_model
  from scenic.projects.unloc import encoders
  from scenic.projects.unloc import heads
  from scenic.projects.unloc import moment_retrieval_base_model
  from scenic.projects.unloc import temporal_localization_base_model
  from scenic.projects.unloc import video_text_fusion
label_desc: Use image node_id 4 for calling the VideoTextSingleTower obj's underlying member method code with example usage: obj.encode_text(inputs, task, train, debug) and returns: text_tokens, None