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_tsv(
      cls,
      num_rows: int = 10,
      train: bool = True,
      filename: str = "criteo",
  ) -> Generator[str, None, None]:
      with tempfile.TemporaryDirectory() as tmpdir:
          path = os.path.join(tmpdir, filename)
          with open(path, "w") as f:
              rows = []
              for _ in range(num_rows):
                  row = []
                  if train:
                      row.append(
                          str(random.randint(*cls.LABEL_VAL_RANGE))
                      )
                  row += [
                      *(
                          str(random.randint(*cls.INT_VAL_RANGE))
                          for _ in range(cls.INT_FEATURE_COUNT)
                      ),
                      *(
                          (
                              "%x"
                              % abs(
                                  hash(
                                      str(
                                          random.randint(
                                              *cls.CAT_VAL_RANGE
                                          )
                                      )
                                  )
                              )
                          ).zfill(8)[:8]
                          for _ in range(cls.CAT_FEATURE_COUNT)
                      ),
                  ]
                  rows.append(row)
              cf = csv.writer(f, delimiter="\t")
              cf.writerows(rows)
          yield path
  
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 1 for calling the CriteoTest obj's underlying member method code with example usage: obj._create_dataset_tsv(cls, num_rows, train, filename) without return types