code: def build_encoder(
      config: Union[DictConfig, "mmf.modules.encoders.Encoder.Config"]
  ):
      from mmf.modules.encoders import Encoder
  
      # If it is not an OmegaConf object, create the object
      if not isinstance(config, DictConfig) and isinstance(
          config, Encoder.Config
      ):
          config = OmegaConf.structured(config)
  
      if "type" in config:
          # Support config initialization in form of
          # encoder:
          #   type: identity # noqa
          #   params:
          #       in_dim: 256
          name = config.type
          if isinstance(name, Enum):
              name = name.value
          params = config.get("params", None)
      else:
          # Structured Config support
          name = config.name
          params = config
  
      encoder_cls = registry.get_encoder_class(name)
  
      # If params were not passed, try generating them from encoder
      # class's default config
      if params is None:
          params = OmegaConf.structured(
              getattr(encoder_cls, "Config", {})
          )
  
      return encoder_cls(params)
  
imports: import logging
  import os
  import warnings
  from enum import Enum
  from typing import Any, Dict, List, Optional, Tuple, Union
  import mmf
  import pytorch_lightning
  import torch
  from mmf.common.meter import Meter
  from mmf.common.registry import registry
  from mmf.datasets.iteration_strategies import ConstantIterationStrategy, IterationStrategy, SizeProportionalIterationStrategy
  from mmf.datasets.processors.processors import Processor
  from mmf.utils.configuration import Configuration, get_global_config
  from mmf.utils.distributed import is_dist_initialized, is_main, is_xla, synchronize
  from mmf.utils.general import get_optimizer_parameters
  from omegaconf import DictConfig, OmegaConf
  from packaging import version
label_desc: Use image node_id 18 for calling a global function with example usage: build_encoder(config) and returns: encoder_cls