code: def _score_target(self, batch, enc_out, src_len, src_map):
      tgt = batch["tgt"]
      tgt_in = tgt[:, :-1, :]
  
      log_probs, attn = self._decode_and_generate(
          tgt_in,
          enc_out,
          batch,
          src_len=src_len,
          src_map=src_map,
      )
  
      log_probs[:, :, self._tgt_pad_idx] = 0
      gold = tgt[:, 1:, :]
      gold_scores = log_probs.gather(2, gold)
      gold_scores = gold_scores.sum(dim=1).view(-1)
      return gold_scores
  
imports: import torch
  from torch.nn.functional import log_softmax
  from torch.nn.utils.rnn import pad_sequence
  import codecs
  from time import time
  from math import exp
  from itertools import count, zip_longest
  from copy import deepcopy
  import onmt.model_builder
  import onmt.decoders.ensemble
  from onmt.constants import DefaultTokens
  from onmt.translate.beam_search import BeamSearch, BeamSearchLM
  from onmt.translate.greedy_search import GreedySearch, GreedySearchLM
  from onmt.utils.misc import tile, set_random_seed, report_matrix
  from onmt.utils.alignment import extract_alignment, build_align_pharaoh
  from onmt.modules.copy_generator import collapse_copy_scores
  from onmt.constants import ModelTask
  from onmt.transforms import TransformPipe
label_desc: Use image node_id 6 for calling the Translator obj's underlying member method code with example usage: obj._score_target(batch, enc_out, src_len, src_map) and returns: gold_scores