class_docstr: Dense video captioning module that encodes a video and generate tokens.
code: def _get_encoder(
      self,
      enc_type: str,
      enc_config: ml_collections.ConfigDict,
      embedder: Optional[nn.Module] = None,
      num_bins: int = 0,
  ):
      if enc_type == "tmp":
          encoder = vit.Encoder(
              mlp_dim=enc_config.get("dim"),
              num_layers=enc_config.get("layers"),
              num_heads=enc_config.get("heads"),
              positional_embedding=enc_config.get("pos_embed"),
              dropout_rate=enc_config.get("dropout_rate"),
              attention_dropout_rate=enc_config.get("dropout_rate"),
              stochastic_depth=enc_config.get("stochastic_depth"),
          )
      elif enc_type == "t5_encoder":
          t5_config = t5_pretrained.CONFIGS[
              enc_config.pretrained_config
          ]
          t5_config["dropout_rate"] = enc_config.get("dropout_rate")
          if num_bins:  # add timestamp tokens to the vocabulary
              t5_config["vocab_size"] = 32128 + num_bins
          encoder = t5_model.T5Encoder(
              **t5_config,
              shared_embedding=embedder,
              name="video_encoder",
          )
      elif enc_type == "cat_encoder":
          encoder = CatEncoder(
              enc_type=enc_type,
              enc_config=enc_config,
              embedder=embedder,
              num_bins=num_bins,
          )
      else:
          raise ValueError(f"Unrecognized encoder type: {enc_type}.")
  
      return encoder
  
imports: import functools
  from typing import Any, Dict, Mapping, Optional, Tuple
  from absl import logging
  import flax.linen
  from flax.training import common_utils
  import jax
  import jax.numpy
  import ml_collections
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import model_utils
  from scenic.projects.baselines import vit
  from scenic.projects.t5 import layers
  from scenic.projects.t5 import model
  from t5x import decoding
  from t5x.models import DecodeFnCallable
label_desc: Use image node_id 1 for calling the DenseVideoCaptioningModule obj's underlying member method code with example usage: obj._get_encoder(enc_type, enc_config, embedder, num_bins) and returns: encoder