code: def __init__(self, cfg: InferConfig) -> None:
      self.cfg = cfg
      self.task = tasks.setup_task(cfg.task)
  
      models, saved_cfg = self.load_model_ensemble()
  
      ### LOAD ADAPTER ####
      ckpt_obj = checkpoint_utils.load_checkpoint_to_cpu(
          self.cfg.common_eval.path
      )
      if "adapter" in ckpt_obj:
          target_lang = self.cfg.dataset.gen_subset.split(":")[0]
          assert target_lang in ckpt_obj["adapter"]
  
          logger.info(f">>> LOADING ADAPTER: {target_lang}")
          ft_obj = ckpt_obj["adapter"][target_lang]
          ft_model = ft_obj["model"]
          cdevice = models[0].w2v_encoder.proj.weight.device
          cdtype = models[0].w2v_encoder.proj.weight.dtype
          ft_proj_out, ft_proj_in = ft_model[
              "w2v_encoder.proj.weight"
          ].shape
          ft_proj = torch.nn.Linear(ft_proj_in, ft_proj_out, bias=True)
          ft_proj.to(device=cdevice, dtype=cdtype)
          models[0].w2v_encoder.proj = ft_proj
          with torch.no_grad():
              for kk, vv in models[0].named_parameters():
                  if kk in ft_model:
                      vv.copy_(ft_model[kk])
          self.task.load_state_dict(ft_obj["task_state"])
          # overwrite gen_subset with master config
          self.cfg.dataset.gen_subset = re.sub(
              "^[\w-]+:",
              saved_cfg["task"]["multi_corpus_keys"] + ":",
              self.cfg.dataset.gen_subset,
          )
      self.models = models
      self.saved_cfg = saved_cfg
      self.tgt_dict = self.task.target_dictionary
  
      self.task.load_dataset(
          self.cfg.dataset.gen_subset,
          task_cfg=saved_cfg.task,
      )
      self.generator = Decoder(cfg.decoding, self.tgt_dict)
      self.gen_timer = StopwatchMeter()
      self.wps_meter = TimeMeter()
      self.num_sentences = 0
      self.total_errors = 0
      self.total_length = 0
  
      self.hypo_words_file = None
      self.hypo_units_file = None
      self.ref_words_file = None
      self.ref_units_file = None
  
      self.progress_bar = self.build_progress_bar()
  
imports: import ast
  import hashlib
  import logging
  import os
  import shutil
  import sys
  import re
  from dataclasses import dataclass, field, is_dataclass
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Tuple, Union
  import editdistance
  import torch
  import torch.distributed
  from examples.speech_recognition.new.decoders.decoder_config import DecoderConfig, FlashlightDecoderConfig
  from examples.speech_recognition.new.decoders.decoder import Decoder
  from fairseq import checkpoint_utils, distributed_utils, progress_bar, tasks, utils
  from fairseq.data.data_utils import post_process
  from fairseq.dataclass.configs import CheckpointConfig, CommonConfig, CommonEvalConfig, DatasetConfig, DistributedTrainingConfig, FairseqDataclass
  from fairseq.logging.meters import StopwatchMeter, TimeMeter
  from fairseq.logging.progress_bar import BaseProgressBar
  from fairseq.models.fairseq_model import FairseqModel
  from omegaconf import OmegaConf
  import hydra
  from hydra.core.config_store import ConfigStore
label_desc: Use image node_id 1 to create a new InferenceProcessor object  with example: obj = InferenceProcessor(cfg)