code: def get_corpora(
      opts, task=CorpusTask.TRAIN, src=None, tgt=None, align=None
  ):
      corpora_dict = {}
      if task == CorpusTask.TRAIN:
          for corpus_id, corpus_dict in opts.data.items():
              if corpus_id != CorpusName.VALID:
                  corpora_dict[corpus_id] = ParallelCorpus(
                      corpus_id,
                      corpus_dict["path_src"],
                      corpus_dict["path_tgt"],
                      corpus_dict["path_align"],
                      n_src_feats=opts.n_src_feats,
                      src_feats_defaults=opts.src_feats_defaults,
                  )
      elif task == CorpusTask.VALID:
          if CorpusName.VALID in opts.data.keys():
              corpora_dict[CorpusName.VALID] = ParallelCorpus(
                  CorpusName.VALID,
                  opts.data[CorpusName.VALID]["path_src"],
                  opts.data[CorpusName.VALID]["path_tgt"]
                  if tgt is None
                  else None,
                  opts.data[CorpusName.VALID]["path_align"],
                  n_src_feats=opts.n_src_feats,
                  src_feats_defaults=opts.src_feats_defaults,
              )
          else:
              return None
      else:
          corpora_dict[CorpusName.INFER] = ParallelCorpus(
              CorpusName.INFER,
              src if src else opts.src,
              tgt if tgt else opts.tgt,
              align if align else None,
              n_src_feats=opts.n_src_feats,
              src_feats_defaults=opts.src_feats_defaults,
          )
      return corpora_dict
  
imports: import os
  from onmt.utils.logging import logger
  from onmt.constants import CorpusName, CorpusTask
  from onmt.transforms import TransformPipe
  from onmt.inputters.text_utils import process, parse_features, append_features_to_text
  from contextlib import contextmanager
  import itertools
label_desc: Use image node_id 2 for calling a global function with example usage: get_corpora(opts, task, src, tgt, align) and returns: corpora_dict, None