code: def _normalized_weighted_sampling(self, weights: Dict[str, float]):
      factor = 1.0 / sum(weights.values())
      normalized_weights = {k: v * factor for k, v in weights.items()}
  
      def sample(candidate_list):
          v = np.random.random()
          agg = 0
          for key in candidate_list:
              agg += normalized_weights[key]
              if agg > v:
                  return key
  
      return sample
  
imports: import os
  from collections import OrderedDict
  from typing import Dict, List, Optional, Tuple
  import numpy
  from fairseq import data, options
  from fairseq.data import ConcatDataset, LanguagePairDataset, NoisingDataset
  from fairseq.data.multi_corpus_sampled_dataset import MultiCorpusSampledDataset
  from fairseq.data.noising import UnsupervisedMTNoising
  from fairseq.tasks import LegacyFairseqTask, register_task
  from pytorch_translate import constants, utils
  from pytorch_translate.data import char_data, data, dictionary, utils, weighted_data
  from pytorch_translate.data.language_pair_upsampling_dataset import LanguagePairUpsamplingDataset
  from pytorch_translate.research.multisource import multisource_data
label_desc: Use image node_id 6 for calling the PytorchTranslateTask obj's underlying member method code with example usage: obj._normalized_weighted_sampling(weights) and returns: sample, key