class_docstr: Doppelganger Simulator for time series generation.
  The codes and algorithm are adapted from https://github.com/fjxmlzn/DoppelGANger.
class_docstr_tok: ["Doppelganger","Simulator","for","time","series","generation",".","The","codes","and","algorithm","are","adapted","from","https",":","\/\/github.com\/fjxmlzn\/DoppelGANger","."]
docstr: Generate synthetic data with similar distribution as training data.
  
  :param sample_num: How many samples to be generated.
  :param batch_size: batch size to generate.
docstr_tok: ["Generate","synthetic","data","with","similar","distribution","as","training","data",".",":","param","sample_num",":","How","many","samples","to","be","generated",".",":","param","batch_size",":","batch","size","to","generate","."]
code: def generate(self, sample_num=1, batch_size=32):
      """
      Generate synthetic data with similar distribution as training data.
  
      :param sample_num: How many samples to be generated.
      :param batch_size: batch size to generate.
      """
      # set to inference mode
      self.model.eval()
      total_generate_num_sample = sample_num
  
      # generate noise and inputs
      real_attribute_input_noise = gen_attribute_input_noise(
          total_generate_num_sample
      )
      addi_attribute_input_noise = gen_attribute_input_noise(
          total_generate_num_sample
      )
      feature_input_noise = gen_feature_input_noise(
          total_generate_num_sample, self.model.length
      )
      feature_input_data = gen_feature_input_data_free(
          total_generate_num_sample,
          self.model.sample_len,
          self.feature_dim,
      )
      real_attribute_input_noise = torch.from_numpy(
          real_attribute_input_noise
      ).float()
      addi_attribute_input_noise = torch.from_numpy(
          addi_attribute_input_noise
      ).float()
      feature_input_noise = torch.from_numpy(
          feature_input_noise
      ).float()
      feature_input_data = torch.from_numpy(feature_input_data).float()
  
      # generate
      features, attributes, gen_flags, lengths = self.model.sample_from(
          real_attribute_input_noise,
          addi_attribute_input_noise,
          feature_input_noise,
          feature_input_data,
          batch_size=batch_size,
      )
  
      # renormalize (max, min)
      features, attributes = renormalize_per_sample(
          features,
          attributes,
          self.model.data_feature_outputs,
          self.model.data_attribute_outputs,
          gen_flags,
          num_real_attribute=self.num_real_attribute,
      )  # -2 for addi attr
  
      # post-process the attributes
      output_list = []
      current_idx = 0
      for i in range(len(self.model.data_attribute_outputs)):
          output_it = self.model.data_attribute_outputs[i]
          if output_it.type_ == OutputType.DISCRETE:
              sub_output = F.softmax(
                  torch.from_numpy(
                      attributes[
                          :, current_idx : current_idx + output_it.dim
                      ]
                  )
              )
              sub_output_discrete = F.one_hot(
                  torch.argmax(sub_output, dim=1),
                  num_classes=output_it.dim,
              )
              output_list.append(sub_output_discrete)
          current_idx += output_it.dim
      attributes = torch.cat(output_list, dim=1).numpy()
  
      return features, attributes, gen_flags, lengths
  
file_path: analytics-zoo/pyzoo/zoo/chronos/simulator/doppelganger_simulator.py
imports: import pickle
  import os
  import numpy
  from zoo.chronos.simulator.doppelganger.util import gen_attribute_input_noise, gen_feature_input_noise, gen_feature_input_data_free, renormalize_per_sample
  from zoo.chronos.simulator.doppelganger.output import OutputType
  import torch
  import torch.nn.functional
label_desc: Use image node_id 3 for calling the DPGANSimulator obj's underlying member method code with example usage: obj.generate(sample_num, batch_size) and returns: features,  attributes,  gen_flags,  lengths