class_docstr: Transformer Model Encoder for sequence to sequence translation.
  
  Attributes:
    config: hyperparameters of the module
class_docstr_tok: ["Transformer","Model","Encoder","for","sequence","to","sequence","translation",".","Attributes",":","config",":","hyperparameters","of","the","module"]
docstr: Applies Transformer model on the inputs.
docstr_tok: ["Applies","Transformer","model","on","the","inputs","."]
code: def __call__(self, x, *, train: bool, debug: bool = False):
      """Applies Transformer model on the inputs."""
      cfg = self.config
  
      # Only spectrogram inputs are implemented for now.
      for modality in x:
          if modality == "spectrogram":
              x_spec = x[modality]
          else:
              assert x[modality] is None
  
      x = []
      if "spectrogram" in cfg.modality_fusion:
          x_spec, _ = temporal_encode(
              x_spec,
              "spectrogram",
              cfg.temporal_encoding_config,
              cfg.patches,
              cfg.emb_dim,
          )
          # TODO(valgab): Have different pos embeddings for different modalities
          x_spec = AddPositionEmbs(config=cfg, name="posembed_input")(
              x_spec
          )
          x.append(x_spec)
      x = jnp.concatenate(x, axis=1)
  
      x = nn.Dropout(rate=cfg.dropout_rate)(x, deterministic=not train)
  
      x = x.astype(cfg.dtype)
  
      # Input Encoder
      encoder_mask = None
      for lyr in range(cfg.num_layers):
          x = Encoder1DBlock(config=cfg, name=f"encoderblock_{lyr}")(
              x, encoder_mask, train=train
          )
  
      encoded = nn.LayerNorm(dtype=cfg.dtype, name="encoder_norm")(x)
  
      return encoded
  
imports: from typing import Any, Dict, Optional, Tuple
  from absl import logging
  from flax import linen
  from flax.training import common_utils
  from immutabledict import immutabledict
  import jax
  from jax import lax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import model_utils
  from scenic.projects.mbt import model
  from scenic.projects.mbt.model import temporal_encode
label_desc: Use image node_id 1 for calling the Encoder obj's underlying member method code with example usage: obj.__call__(x) and returns: encoded