code: def find_subsequence_location(sequence, subsequence):
      """Finds the start and end index of the first occurance
      of a given subsequence within a larger list. Returns
      the two indices corresponding to the postition of
      the first and last token of the subseqeunce.
      Assumes subsequence is known to be in sequence.
      """
      assert len(sequence) >= len(subsequence), "subsequence too long"
  
      start_idx = None
      next_subseq_token = subsequence[0]
      next_subsequence_idx = 1
  
      for seq_idx, token in enumerate(sequence):
          if token == next_subseq_token:
              if start_idx is None:
                  start_idx = seq_idx
  
              if next_subsequence_idx == len(subsequence):
                  end_idx = seq_idx
                  return start_idx, end_idx
              else:
                  next_subseq_token = subsequence[next_subsequence_idx]
                  next_subsequence_idx += 1
          else:
              start_idx = None
              next_subseq_token = subsequence[0]
              next_subsequence_idx = 1
  
      raise ValueError("Subsequence not found in sequence")
  
file_path: NeMo/nemo/collections/nlp/data/language_modeling/megatron/base_prompt_learning_dataset.py
imports: import torch
  from nemo.collections.nlp.modules.common import VirtualPromptSource
  from nemo.core import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: find_subsequence_location(sequence, subsequence) and returns: start_idx,  end_idx