code: def _prepare_val_features(
      self, samples: Any, tokenized_samples: Any, pad_on_right: bool
  ):
      # Since one example might give us several features if it has a long context, we need a map from a feature to
      # its corresponding example. This key gives us just that.
      sample_mapping = tokenized_samples.pop(
          "overflow_to_sample_mapping"
      )
  
      # For evaluation, we will need to convert our predictions to substrings of the context, so we keep the
      # corresponding example_id, and we will store the offset mappings.
      tokenized_samples["example_id"] = []
      tokenized_samples["context"] = []
      tokenized_samples["answer"] = []
  
      for i in range(len(tokenized_samples["input_ids"])):
          # Grab the sequence corresponding to that example (to know what is the context and what is the question).
          sequence_ids = tokenized_samples.sequence_ids(i)
          context_index = 1 if pad_on_right else 0
  
          # One example can give several spans, this is the index of the example containing this span of text.
          sample_index = sample_mapping[i]
          tokenized_samples["example_id"].append(
              samples["id"][sample_index]
          )
          tokenized_samples["context"].append(
              samples["context"][sample_index]
          )
          if "answer" in samples:
              tokenized_samples["answer"].append(
                  samples["answer"][sample_index]
              )
  
          # Set to None the offset_mapping that are not part of the context, so it's easy to determine if a token
          # position is part of the context or not.
          tokenized_samples["offset_mapping"][i] = [
              (o if sequence_ids[k] == context_index else None)
              for k, o in enumerate(
                  tokenized_samples["offset_mapping"][i]
              )
          ]
  
      return tokenized_samples
  
file_path: lightning-flash/src/flash/text/question_answering/collate.py
imports: from dataclasses import dataclass
  from typing import Any, Optional, Union
  from flash.core.data.io.input import DataKeys
  from flash.core.integrations.transformers.collate import TransformersCollate
  from flash.core.model import Task
label_desc: Use image node_id 2 for calling the TextQuestionAnsweringCollate obj's underlying member method code with example usage: obj._prepare_val_features(samples, tokenized_samples, pad_on_right) and returns: tokenized_samples