code: def get_pooling_layer(
      cfg: Wav2Vec2ClassificationConfig,
      encoder_embed_dim: int,
      num_targets: int,
      encoder_layers: int,
  ):
      assert cfg.pooling == "mean"
      if cfg.pooling == "first_token":
          return FirstToken(cfg, encoder_embed_dim, num_targets)
      # elif cfg.pooling == "mean":
      #     return MeanPooling(cfg, encoder_embed_dim, num_targets)
      elif cfg.pooling == "mean":
          return MeanPoolingFast(cfg, encoder_embed_dim, num_targets)
      elif cfg.pooling == "mean_amsoftmax":
          return MeanPoolingFastAMSoftmax(
              cfg, encoder_embed_dim, num_targets
          )
      elif cfg.pooling == "max":
          return MaxPoolingFast(cfg, encoder_embed_dim, num_targets)
      elif cfg.pooling == "elmo":
          return LayerWeightedMeanPooling(
              cfg, encoder_embed_dim, num_targets, encoder_layers
          )
      else:
          raise NotImplementedError(
              f"{cfg.pooling} has not been implemented yet."
          )
  
imports: import contextlib
  import logging
  from argparse import Namespace
  from dataclasses import dataclass, field
  from typing import Any, Optional
  import torch
  import torch.nn
  import torch.nn.functional
  from omegaconf import II, MISSING, open_dict
  from fairseq import checkpoint_utils, tasks, utils
  from fairseq.dataclass import ChoiceEnum, FairseqDataclass
  from fairseq.dataclass.utils import convert_namespace_to_omegaconf
  from fairseq.models import BaseFairseqModel, FairseqEncoder, register_model
  from fairseq.models.wav2vec.wav2vec2 import MASKING_DISTRIBUTION_CHOICES, Wav2Vec2Config
  from fairseq.models.wav2vec.wav2vec2_asr import Embedding, Linear, Wav2VecEncoder, Wav2Vec2AsrConfig
  from fairseq.tasks import FairseqTask
label_desc: Use image node_id 1 for calling a global function with example usage: get_pooling_layer(cfg, encoder_embed_dim, num_targets, encoder_layers) and returns: FirstToken, MeanPoolingFast, MeanPoolingFastAMSoftmax, MaxPoolingFast, LayerWeightedMeanPooling