class_docstr: Class for managing efficient loss computation. Handles
  accumulating multiple loss computations.
  
  Args:
      criterion (:obj:`nn. loss function`) : NLLoss or customed loss
      generator (:obj:`nn.Module`) :
      copy_attn (bool): whether copy attention mechanism is on/off
      lambda_coverage: Hyper-param to apply coverage attention if any
      lambda_align: Hyper-param for alignment loss
      tgt_shift_index (int): 1 for NMT, 0 for LM
      vocab: target vocab (for copy attention score calculation)
           module that maps the output of the decoder to a
           distribution over the target vocabulary.
      lm_generator (:obj:`ctranslate2.Generator`): LM Generator
      lm_prior_lambda (float): weight of LM model in loss
      lm_prior_tau (float): scaler for LM loss
class_docstr_tok: ["Class","for","managing","efficient","loss","computation",".","Handles","accumulating","multiple","loss","computations",".","Args",":","criterion","(",":","obj",":","`","nn",".","loss","function","`",")",":","NLLoss","or","customed","loss","generator","(",":","obj",":","`","nn.Module","`",")",":","copy_attn","(","bool",")",":","whether","copy","attention","mechanism","is","on\/off","lambda_coverage",":","Hyper-param","to","apply","coverage","attention","if","any","lambda_align",":","Hyper-param","for","alignment","loss","tgt_shift_index","(","int",")",":","1","for","NMT",",","0","for","LM","vocab",":","target","vocab","(","for","copy","attention","score","calculation",")","module","that","maps","the","output","of","the","decoder","to","a","distribution","over","the","target","vocabulary",".","lm_generator","(",":","obj",":","`","ctranslate2.Generator","`",")",":","LM","Generator","lm_prior_lambda","(","float",")",":","weight","of","LM","model","in","loss","lm_prior_tau","(","float",")",":","scaler","for","LM","loss"]
docstr: Mask the prompt in the target side of the batch examples in order
      to set the loss of the prompt to zero.
  For finetuning on specific tasks.
  The end of the prompt must be indicated by `the DefaultTokens.MASK_BEFORE`
      placeholder.
  The masks are supposed to be properly handled by the loss criterion
      (e.g. nn.CrossEntropyLoss ).
  
  Args:
      batch: The current batch.
docstr_tok: ["Mask","the","prompt","in","the","target","side","of","the","batch","examples","in","order","to","set","the","loss","of","the","prompt","to","zero",".","For","finetuning","on","specific","tasks",".","The","end","of","the","prompt","must","be","indicated","by","`","the","DefaultTokens.MASK_BEFORE","`","placeholder",".","The","masks","are","supposed","to","be","properly","handled","by","the","loss","criterion","(","e.g",".","nn.CrossEntropyLoss",")",".","Args",":","batch",":","The","current","batch","."]
code: def ignore_prompt(self, batch):
      """
      Mask the prompt in the target side of the batch examples in order
          to set the loss of the prompt to zero.
      For finetuning on specific tasks.
      The end of the prompt must be indicated by `the DefaultTokens.MASK_BEFORE`
          placeholder.
      The masks are supposed to be properly handled by the loss criterion
          (e.g. nn.CrossEntropyLoss ).
  
      Args:
          batch: The current batch.
      """
      # Create a mask with zeros at prompt positions and ones at answer postions.
      mask = batch["src"].squeeze(dim=2) == self.padding_idx
      mask = torch.cumsum(mask.int(), 1)
      mask = mask.unsqueeze(-1)
      # Apply the mask on the target side.
      batch["tgt"] *= mask.int()
      # Put the padding token index at the prompt positions.
      batch["tgt"] += self.padding_idx * (1 - mask.int())
      return batch
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  import onmt
  from onmt.modules.sparse_losses import SparsemaxLoss
  from onmt.modules.sparse_activations import LogSparsemax
  from onmt.constants import ModelTask, DefaultTokens
  from onmt.modules.copy_generator import collapse_copy_scores
  from onmt.model_builder import load_test_model
label_desc: Use image node_id 11 for calling the LossCompute obj's underlying member method code with example usage: obj.ignore_prompt(batch) and returns: batch