class_docstr: Dataset of synthetically generated demonstrations.
docstr: Builds a dataset of synthetic demonstrations.
  
  Args:
      tensor_size (int): Size of the tensor.
      n_data (int): Number of demonstrations to generate.
      limit_rank (int): Maximum rank of the generated tensors.
      prob_distr (Callable): Probability distribution to use to generate
      the tensors.
      n_prev_actions (int): Number of previous actions to use as input.
      device (str): Name of the torch device to use.
      n_steps (int): Number of steps to perform in the environment.
      random_seed (int, optional): Random seed to use.
docstr_tok: ["Builds","a","dataset","of","synthetic","demonstrations",".","Args",":","tensor_size","(","int",")",":","Size","of","the","tensor",".","n_data","(","int",")",":","Number","of","demonstrations","to","generate",".","limit_rank","(","int",")",":","Maximum","rank","of","the","generated","tensors",".","prob_distr","(","Callable",")",":","Probability","distribution","to","use","to","generate","the","tensors",".","n_prev_actions","(","int",")",":","Number","of","previous","actions","to","use","as","input",".","device","(","str",")",":","Name","of","the","torch","device","to","use",".","n_steps","(","int",")",":","Number","of","steps","to","perform","in","the","environment",".","random_seed","(","int",",","optional",")",":","Random","seed","to","use","."]
code: def __init__(
      self,
      tensor_size,
      n_data,
      limit_rank,
      prob_distr,
      n_prev_actions: int,
      device: str,
      n_steps: int,
      random_seed=None,
  ):
      """Builds a dataset of synthetic demonstrations.
  
      Args:
          tensor_size (int): Size of the tensor.
          n_data (int): Number of demonstrations to generate.
          limit_rank (int): Maximum rank of the generated tensors.
          prob_distr (Callable): Probability distribution to use to generate
          the tensors.
          n_prev_actions (int): Number of previous actions to use as input.
          device (str): Name of the torch device to use.
          n_steps (int): Number of steps to perform in the environment.
          random_seed (int, optional): Random seed to use.
      """
      self.device = device
      self.len_data = 0
      self.n_prev_actions = n_prev_actions
      self.limit_rank = limit_rank
      self.n_steps = n_steps
      self.save_dir = os.path.join(SAVE_DIR_SYNT, f"size_{tensor_size}")
      Path(self.save_dir).mkdir(parents=True, exist_ok=True)
      number_of_triplets = (
          len(list(Path(self.save_dir).glob("*.pt"))) // 2
      )
      if number_of_triplets < n_data:
          self.len_data = number_of_triplets
          for i, (output_tensor, list_of_triplets) in enumerate(
              generate_synthetic_data(
                  tensor_size,
                  n_data - number_of_triplets,
                  limit_rank,
                  prob_distr,
                  random_seed,
              )
          ):
              torch.save(
                  output_tensor,
                  os.path.join(
                      self.save_dir, f"output_tensor_{self.len_data}.pt"
                  ),
              )
              torch.save(
                  list_of_triplets,
                  os.path.join(
                      self.save_dir,
                      f"list_of_triplets_{self.len_data}.pt",
                  ),
              )
              self.len_data += 1
      else:
          self.len_data = n_data
  
imports: import json
  import os
  import shutil
  import tempfile
  from pathlib import Path
  from typing import List, Tuple
  import numpy
  import torch
  from torch.utils.data import Dataset
  from open_alpha_tensor.core.data.generation import generate_synthetic_data
  from open_alpha_tensor.core.data.utils import get_scalars, map_triplet_to_action
label_desc: Use image node_id 1 to create a new SyntheticDataBuffer object from inherited base classes: Dataset with example: obj = SyntheticDataBuffer(tensor_size, n_data, limit_rank, prob_distr, n_prev_actions, device, n_steps, random_seed)