class_docstr: Class for Stanford NLP SHP dataset from HuggingFace
docstr: Save the dataset in the format required by RLHF
  
  Args:
      dataset_folder (str): path to the folder where the dataset
          will be saved
      number_of_samples (int): number of samples to take from the
          dataset
      reverse (bool, optional): sort the dataset in descending order.
          Defaults to True.
docstr_tok: ["Save","the","dataset","in","the","format","required","by","RLHF","Args",":","dataset_folder","(","str",")",":","path","to","the","folder","where","the","dataset","will","be","saved","number_of_samples","(","int",")",":","number","of","samples","to","take","from","the","dataset","reverse","(","bool",",","optional",")",":","sort","the","dataset","in","descending","order",".","Defaults","to","True","."]
code: def save_dataset(
      self,
      dataset_folder: str,
      number_of_samples: int,
      reverse: bool = True,
  ) -> None:
      """Save the dataset in the format required by RLHF
  
      Args:
          dataset_folder (str): path to the folder where the dataset
              will be saved
          number_of_samples (int): number of samples to take from the
              dataset
          reverse (bool, optional): sort the dataset in descending order.
              Defaults to True.
      """
  
      print("Generate datasets for RLHF")
  
      # take the train and test dataset to create the finetuning dataset
      conversations = self.reformat_dataset(self.dataset["train"])
      conversations.extend(self.reformat_dataset(self.dataset["test"]))
  
      # sort conversations by length of user_input + completion
      conversations = self.sort_conversation(
          conversations, reverse=reverse
      )
  
      # save actor training data
      with open(f"{dataset_folder}/actor_training_data.json", "w") as f:
          json.dump(conversations, f, indent=4)
  
      # take N samples and sort them
      conversations = self.take_n_samples(
          conversations, number_of_samples
      )
      conversations = self.sort_conversation(
          conversations, reverse=reverse
      )
  
      # save reward training data
      with open(
          f"{dataset_folder}/reward_training_data.json", "w"
      ) as f:
          json.dump(conversations, f, indent=4)
  
      # take the validation dataset for rlhf
      conversations = self.reformat_dataset(self.dataset["validation"])
      # sort the validation dataset
      conversations = self.sort_conversation(
          conversations,
          only_input=True,
          reverse=reverse,
      )
      # save rlhf training data
      with open(f"{dataset_folder}/rlhf_training_data.json", "w") as f:
          json.dump(conversations, f, indent=4)
  
      print("Generation Completed")
  
imports: import json
  import os
  import numpy
  from beartype.typing import Dict, List, Union
  from datasets import load_dataset
  from chatllama.rlhf.config import Config, ConfigActor, ConfigReward
  from chatllama.rlhf.reward import RewardModel, CriticModel
  from chatllama.rlhf.actor import ActorModel
label_desc: Use image node_id 3 for calling the StanfordNLPSHPDataset obj's underlying member method code with example usage: obj.save_dataset(dataset_folder, number_of_samples, reverse) without return types