


'''simple docstring'''





def   _UpperCamelCase				(						lowerCAmelCase_  ,						lowerCAmelCase_   )						->float:
   if discount_rate < 0:
      raise ValueError("""Discount rate cannot be negative"""   )
   if not cash_flows:
      raise ValueError("""Cash flows list cannot be empty"""   )
   UpperCAmelCase							=     sum(
       cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(lowerCamelCase_   )   )
   return round(lowerCamelCase_  ,						ndigits=2   )


if __name__ == "__main__":
 import doctest

 doctest.testmod()







import multiprocessing
import time

from arguments import PretokenizationArguments
from datasets import load_dataset

from transformers import AutoTokenizer, HfArgumentParser
def   _UpperCamelCase				(						lowerCAmelCase_   )						->int:
   UpperCAmelCase							=     {}
   UpperCAmelCase							=     tokenizer(example["""content"""]  ,						truncation=lowerCAmelCase_   )["""input_ids"""]
   UpperCAmelCase							=     len(example["""content"""]   ) / len(output["""input_ids"""]   )
   return output


__a     =			HfArgumentParser(PretokenizationArguments)
__a     =			parser.parse_args()
if args.num_workers is None:
 __a     =			multiprocessing.cpu_count()
__a     =			AutoTokenizer.from_pretrained(args.tokenizer_dir)

__a     =			time.time()
__a     =			load_dataset(args.dataset_name, split="""train""")
print(F"""Dataset loaded in {time.time()-t_start:.2f}s""")

__a     =			time.time()
__a     =			ds.map(
    tokenize,
    num_proc=args.num_workers,
    remove_columns=[
        """repo_name""",
        """path""",
        """copies""",
        """size""",
        """content""",
        """license""",
        """hash""",
        """line_mean""",
        """line_max""",
        """alpha_frac""",
        """autogenerated""",
    ],
)
print(F"""Dataset tokenized in {time.time()-t_start:.2f}s""")

__a     =			time.time()
ds.push_to_hub(args.tokenized_data_repo)







print(F"""Data pushed to the hub in {time.time()-t_start:.2f}s""")



