code: def _addcopykeys(vocabs, example):
      """Create copy-vocab and numericalize with it.
      In-place adds ``"src_map"`` to ``example``. That is the copy-vocab
      numericalization of the tokenized ``example["src"]``. If ``example``
      has a ``"tgt"`` key, adds ``"alignment"`` to example. That is the
      copy-vocab numericalization of the tokenized ``example["tgt"]``. The
      alignment has an initial and final UNK token to match the BOS and EOS
      tokens.
      Args:
          vocabs
          example (dict): An example dictionary with a ``"src"`` key and
              maybe a ``"tgt"`` key. (This argument changes in place!)
      Returns:
          ``example``, changed as described.
      """
      src = example["src"]["src"].split()
      src_ex_vocab = pyonmttok.build_vocab_from_tokens(
          Counter(src),
          maximum_size=0,
          minimum_frequency=1,
          special_tokens=[
              DefaultTokens.UNK,
              DefaultTokens.PAD,
              DefaultTokens.BOS,
              DefaultTokens.EOS,
          ],
      )
      src_ex_vocab.default_id = src_ex_vocab[DefaultTokens.UNK]
      # make a small vocab containing just the tokens in the source sequence
  
      # Map source tokens to indices in the dynamic dict.
      example["src_map"] = src_ex_vocab(src)
      example["src_ex_vocab"] = src_ex_vocab
  
      if example["tgt"] is not None:
          if vocabs["data_task"] == ModelTask.SEQ2SEQ:
              tgt = (
                  [DefaultTokens.UNK]
                  + example["tgt"]["tgt"].split()
                  + [DefaultTokens.UNK]
              )
          elif vocabs["data_task"] == ModelTask.LANGUAGE_MODEL:
              tgt = example["tgt"]["tgt"].split() + [DefaultTokens.UNK]
          example["alignment"] = src_ex_vocab(tgt)
      return example
  
file_path: OpenNMT-py/onmt/inputters/text_utils.py
imports: import torch
  import pyonmttok
  from onmt.constants import DefaultTokens, CorpusTask, ModelTask
  from torch.nn.utils.rnn import pad_sequence
  from onmt.utils.logging import logger
  from collections import Counter
label_desc: Use image node_id 10 for calling a global function with example usage: _addcopykeys(vocabs, example) and returns: example