code: def _packed_seq_test(self, tokenizer, answer_only_loss=True):
      try:
          expected_output = create_data_points(
              TEMP_FILE, answer_only_loss
          )
          test_dataset = GPTSFTPackedDataset(
              TEMP_FILE,
              tokenizer,
              label_key="output",
              truncation_field="input",
              prompt_template="{input} {output}",
              answer_only_loss=answer_only_loss,
          )
          batch = [data for data in test_dataset]
          model_input = test_dataset.collate_fn(batch)
  
          for i in range(len(batch)):
              for output_key in (
                  "tokens",
                  "labels",
                  "loss_mask",
                  "position_ids",
                  "cu_seqlens",
              ):
                  expected = expected_output[i][output_key]
                  # remove padding in the actual results
                  actual = model_input[output_key][i][
                      : len(expected)
                  ].tolist()
                  print("expected", expected, "actual", actual)
                  if output_key == "cu_seqlens":
                      # skip the last value of cu_seqlens since it was changed to the padded length for FP8 training
                      actual[-1] = expected[-1]
                  assert (
                      expected == actual
                  ), f"{output_key} does not match"
  
      finally:
          os.remove(TEMP_FILE)
  
file_path: NeMo/tests/collections/nlp/test_packed_sft_dataset.py
imports: import os
  import numpy
  import pytest
  from nemo.collections.nlp.data.language_modeling.megatron.gpt_sft_dataset import GPTSFTPackedDataset
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_nmt_tokenizer
label_desc: Use image node_id 1 for calling the TestGPTSFTPackedDataset obj's underlying member method code with example usage: obj._packed_seq_test(tokenizer, answer_only_loss) without return types