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 _create_dataset_npys(
      cls,
      num_rows: int = 10,
      filename: Optional[str] = "criteo",
      filenames: Optional[List[str]] = None,
      generate_dense: bool = True,
      generate_sparse: bool = True,
      generate_labels: bool = True,
      dense: Optional[np.ndarray] = None,
      sparse: Optional[np.ndarray] = None,
      labels: Optional[np.ndarray] = None,
  ) -> Generator[Tuple[str, ...], None, None]:
      with tempfile.TemporaryDirectory() as tmpdir:
          if filenames is None:
              filenames = [filename]
  
          paths = []
          for filename in filenames:
              filename = none_throws(filename)
  
              if generate_dense:
                  dense_path = os.path.join(
                      tmpdir, filename + "_dense.npy"
                  )
                  if dense is None:
                      dense = np.random.random(
                          (num_rows, INT_FEATURE_COUNT)
                      ).astype(np.float32)
                  np.save(dense_path, dense)
                  paths.append(dense_path)
  
              if generate_sparse:
                  sparse_path = os.path.join(
                      tmpdir, filename + "_sparse.npy"
                  )
                  if sparse is None:
                      sparse = np.random.randint(
                          cls.CAT_VAL_RANGE[0],
                          cls.CAT_VAL_RANGE[1] + 1,
                          size=(num_rows, CAT_FEATURE_COUNT),
                          dtype=np.int32,
                      )
                  np.save(sparse_path, sparse)
                  paths.append(sparse_path)
  
              if generate_labels:
                  labels_path = os.path.join(
                      tmpdir, filename + "_labels.npy"
                  )
                  if labels is None:
                      labels = np.random.randint(
                          cls.LABEL_VAL_RANGE[0],
                          cls.LABEL_VAL_RANGE[1] + 1,
                          size=(num_rows, 1),
                          dtype=np.int32,
                      )
                  np.save(labels_path, labels)
                  paths.append(labels_path)
  
          yield tuple(paths)
  
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 3 for calling the CriteoTest obj's underlying member method code with example usage: obj._create_dataset_npys(cls, num_rows, filename, filenames, generate_dense, generate_sparse, generate_labels, dense, sparse, labels) without return types