code: def wow_get_batch_context(self, batch, orig_fun=None):
      """
      Set the beam context for n-gram context blocking specific for WoW data.
  
      For WoW, we don't want to consider the knowledge in the input for the context beam
      blocking. That's why we mask it out here.
      """
      ctxts = orig_fun(batch)
      knowledge_start_id = self.dict.txt2vec(TOKEN_KNOWLEDGE)
      knowledge_end_id = self.dict.txt2vec(TOKEN_END_KNOWLEDGE)
  
      def mask_ctxttensor_between_sublists(
          ctxts: torch.Tensor, sub1: List[int], sub2: List[int]
      ) -> torch.Tensor:
          """
          Generate a mask that masks out the context between sub1 and sub2.
          """
          mask = []
          for ctxt in ctxts:
              mask_idxs = []
              should_copy = False
              idx_pointer = 0
              id_to_match = sub1
              for j, token in enumerate(ctxt.cpu().numpy()):
                  if token == id_to_match[idx_pointer]:
                      idx_pointer += 1
                      if idx_pointer == 1 and id_to_match == sub1:
                          mask_idxs.append([j])
                      elif idx_pointer >= len(id_to_match):
                          should_copy = id_to_match == sub1
                          idx_pointer = 0
                          id_to_match = (
                              sub2 if (id_to_match == sub1) else sub1
                          )
                          mask_idxs[-1].append(j)
                      else:
                          mask_idxs[-1].append(j)
                  elif should_copy:
                      mask_idxs[-1].append(j)
                  elif idx_pointer > 0:
                      idx_pointer = 0
                      del mask_idxs[-1]
              mask.append(
                  [
                      0
                      if idx in [i for sl in mask_idxs for i in sl]
                      else 1
                      for idx in range(len(ctxt))
                  ]
              )
          return torch.LongTensor(mask).to(ctxts.device)
  
      ctxts *= mask_ctxttensor_between_sublists(
          ctxts, knowledge_start_id, knowledge_end_id
      )
      return ctxts
  
imports: from copy import deepcopy
  from typing import Optional, List
  from types import MethodType
  from collections import defaultdict
  from nltk.tokenize import sent_tokenize
  from nltk.corpus import stopwords
  import random
  import spacy
  import torch
  from parlai.core.agents import create_agent, create_agent_from_shared
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.message import Message
  from parlai.core.agents import Agent
  from parlai.core.metrics import F1Metric
  from parlai.agents.rag.args import setup_rag_args
  from parlai.agents.bart.bart import BartAgent
  from parlai.core.metrics import normalize_answer
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_NOCHOSEN
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_KNOWLEDGE, TOKEN_END_KNOWLEDGE
label_desc: Use image node_id 2 for calling a global function with example usage: wow_get_batch_context(batch, orig_fun) and returns: ctxts, torch