code: def _get_feature_weights_dict(feature_weights,  # type: FeatureWeights
                                feature_fn        # type: Optional[Callable[[str], str]]
                                ):
      # type: (...) -> Dict[str, Tuple[float, Tuple[str, int]]]
      
      return {
          # (group, idx) is an unique feature identifier, e.g. ('pos', 2)
          feat_name: (fw.weight, (group, idx))
          for group in ['pos', 'neg']
          for idx, fw in enumerate(getattr(feature_weights, group))
          for feat_name in _get_features(fw.feature, feature_fn)
      }
docs: Return {feat_name: (weight, (group, idx))} mapping.