class_docstr: Superclass with helper functions for tests related to Criteo dataset. Helper
  functions include those that create mini mock/random datasets and some functions
  that validate samples returned by the dataset.
class_docstr_tok: ["Superclass","with","helper","functions","for","tests","related","to","Criteo","dataset",".","Helper","functions","include","those","that","create","mini","mock\/random","datasets","and","some","functions","that","validate","samples","returned","by","the","dataset","."]
code: def _validate_sample(
      self, sample: Dict[str, Any], train: bool = True
  ) -> None:
      if train:
          self.assertEqual(
              len(sample),
              self.INT_FEATURE_COUNT + self.CAT_FEATURE_COUNT + 1,
          )
          label_val = sample["label"]
          self.assertTrue(
              self.LABEL_VAL_RANGE[0]
              <= label_val
              <= self.LABEL_VAL_RANGE[1]
          )
      else:
          self.assertEqual(
              len(sample),
              self.INT_FEATURE_COUNT + self.CAT_FEATURE_COUNT,
          )
      for idx in range(self.INT_FEATURE_COUNT):
          int_val = sample[f"int_{idx}"]
          self.assertTrue(
              self.INT_VAL_RANGE[0] <= int_val <= self.INT_VAL_RANGE[1]
          )
      for idx in range(self.CAT_FEATURE_COUNT):
          cat_val = int(sample[f"cat_{idx}"], 16)
          self.assertTrue(0 <= cat_val <= 16**8 - 1)
  
file_path: torchrec/torchrec/datasets/test_utils/criteo_test_utils.py
imports: import contextlib
  import csv
  import os
  import random
  import tempfile
  import unittest
  from typing import Any, Dict, Generator, List, Optional, Tuple
  import numpy
  from pyre_extensions import none_throws
  from torchrec.datasets.criteo import CAT_FEATURE_COUNT, INT_FEATURE_COUNT
label_desc: Use image node_id 2 for calling the CriteoTest obj's underlying member method code with example usage: obj._validate_sample(sample, train) without return types