def get_pattern_dataset(n=100000,
                        num_patterns=3,
                        pattern_size=50,
                        selective=False,
                        num_patterns_store=None):
  """Generates a dataset of sequences of patterns and retrieval targets.

  Args:
    n: Number of examples
    num_patterns: Number of unique patterns in the sequence
    pattern_size: Dimensionality of each pattern
    selective (bool): True if only a subset of patterns needs to be stored.
    num_patterns_store: Number of patterns to store if selective=True.

  Returns:
    A tf.data.Dataset created from a dict with property "seqs,"
    containing the sequences of randomly generated binary patterns, and
    "targets," containing the ground-truth pattern to retrieve for the last
    degraded query pattern in the sequence.
  """
  seqs = []
  targets = []

  for _ in range(n):
    if selective:
      if num_patterns_store is None:
        num_patterns_store = num_patterns // 10
      seq, target, _, _ = generate_pattern_data_selective(
          num_patterns, num_patterns_store, pattern_size)
    else:
      seq, target, _, _ = generate_pattern_data(num_patterns, pattern_size)

    seqs.append(seq)
    targets.append(target)

  return tf.data.Dataset.from_tensor_slices({
      "seqs": np.array(seqs, dtype=np.float32),
      "targets": np.array(targets, dtype=np.int32)
  })
Generates a dataset of sequences of patterns and retrieval targets.

  Args:
    n: Number of examples
    num_patterns: Number of unique patterns in the sequence
    pattern_size: Dimensionality of each pattern
    selective (bool): True if only a subset of patterns needs to be stored.
    num_patterns_store: Number of patterns to store if selective=True.

  Returns:
    A tf.data.Dataset created from a dict with property "seqs,"
    containing the sequences of randomly generated binary patterns, and
    "targets," containing the ground-truth pattern to retrieve for the last
    degraded query pattern in the sequence.
  
language/labs/memory/synthetic_dataset.py