


import multiprocessing
import time

from arguments import PretokenizationArguments
from datasets import load_dataset

from transformers import AutoTokenizer, HfArgumentParser





def   _UpperCAmelCase       (     UpperCAmelCase      :			Union[str, Any]      ):
      """simple docstring"""




      __lowerCamelCase     :      Union[str, Any]       						=						{}
      __lowerCamelCase     :      Union[str, Any]       						=						tokenizer(example["""content"""]						,	truncation=UpperCAmelCase      )["""input_ids"""]
      __lowerCamelCase     :      Any       						=						len(example["""content"""]      ) / len(output["""input_ids"""]      )
      return output


__UpperCamelCase    :						Union[str, Any]     =							HfArgumentParser(PretokenizationArguments)
__UpperCamelCase    :						Dict     =							parser.parse_args()
if args.num_workers is None:
    __UpperCamelCase    :						Optional[int]     =							multiprocessing.cpu_count()
__UpperCamelCase    :						List[str]     =							AutoTokenizer.from_pretrained(args.tokenizer_dir)

__UpperCamelCase    :						List[Any]     =							time.time()
__UpperCamelCase    :						Optional[int]     =							load_dataset(args.dataset_name, split='train')
print(F'''Dataset loaded in {time.time()-t_start:.2f}s''')

__UpperCamelCase    :						List[str]     =							time.time()
__UpperCamelCase    :						Union[str, Any]     =							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''')

__UpperCamelCase    :						List[str]     =							time.time()
ds.push_to_hub(args.tokenized_data_repo)




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







import qiskit





def   _UpperCAmelCase       (     UpperCAmelCase      :			int						,	UpperCAmelCase      :			int      ):
      """simple docstring"""




      __lowerCamelCase     :      Dict       						=						qiskit.Aer.get_backend("""aer_simulator"""      )

      __lowerCamelCase     :      Dict       						=						qiskit.QuantumCircuit(4						,	2      )
      # encode inputs in qubits 0 and 1
      if bita == 1:
            qc_ha.x(0      )
      if bita == 1:
            qc_ha.x(1      )
      qc_ha.barrier()

      # use cnots to write XOR of the inputs on qubit2
      qc_ha.cx(0						,	2      )
      qc_ha.cx(1						,	2      )

      # use ccx / toffoli gate to write AND of the inputs on qubit3
      qc_ha.ccx(0						,	1						,	3      )
      qc_ha.barrier()

      # extract outputs
      qc_ha.measure(2						,	0      )  # extract XOR value
      qc_ha.measure(3						,	1      )  # extract AND value

      # Execute the circuit on the qasm simulator
      __lowerCamelCase     :      str       						=						qiskit.execute(UpperCAmelCase						,	UpperCAmelCase						,	shots=1_000      )

      # Return the histogram data of the results of the experiment
      return job.result().get_counts(UpperCAmelCase      )


if __name__ == "__main__":
    __UpperCamelCase    :						List[str]     =							half_adder(1, 1)
    print(F'''Half Adder Output Qubit Counts: {counts}''')



