





import math

import qiskit




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE = 1		,						_SCREAMING_SNAKE_CASE = 1		,						_SCREAMING_SNAKE_CASE = 1		)    ->       qiskit.result.counts.Counts:
  if (
      isinstance(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)
      or isinstance(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)
      or isinstance(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)
  ):
    raise TypeError('inputs must be integers.'		)

  if (input_a < 0) or (input_a < 0) or (carry_in < 0):
    raise ValueError('inputs must be positive.'		)

  if (
      (math.floor(_SCREAMING_SNAKE_CASE		) != input_a)
      or (math.floor(_SCREAMING_SNAKE_CASE		) != input_a)
      or (math.floor(_SCREAMING_SNAKE_CASE		) != carry_in)
  ):
    raise ValueError('inputs must be exact integers.'		)

  if (input_a > 2) or (input_a > 2) or (carry_in > 2):
    raise ValueError('inputs must be less or equal to 2.'		)

  # build registers
  lowercase__           =  qiskit.QuantumRegister(4		,						'qr'		)
  lowercase__           =  qiskit.ClassicalRegister(2		,						'cr'		)
  # list the entries
  lowercase__           =  [input_a, input_a, carry_in]

  lowercase__           =  qiskit.QuantumCircuit(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)

  for i in range(0		,						3		):
    if entry[i] == 2:
      quantum_circuit.h(_SCREAMING_SNAKE_CASE		)  # for hadamard entries
    elif entry[i] == 1:
      quantum_circuit.x(_SCREAMING_SNAKE_CASE		)  # for 1 entries
    elif entry[i] == 0:
      quantum_circuit.i(_SCREAMING_SNAKE_CASE		)  # for 0 entries

    # build the circuit
  quantum_circuit.ccx(0		,						1		,						3		)  # ccx = toffoli gate
  quantum_circuit.cx(0		,						1		)
  quantum_circuit.ccx(1		,						2		,						3		)
  quantum_circuit.cx(1		,						2		)
  quantum_circuit.cx(0		,						1		)

  quantum_circuit.measure([2, 3]		,						_SCREAMING_SNAKE_CASE		)  # measure the last two qbits

  lowercase__           =  qiskit.Aer.get_backend('aer_simulator'		)
  lowercase__           =  qiskit.execute(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		,						shots=1000		)

  return job.result().get_counts(_SCREAMING_SNAKE_CASE		)


if __name__ == "__main__":
      print(f'''Total sum count for state is: {quantum_full_adder(1, 1, 1)}''')









import argparse

import torch
from torch import nn

from transformers import MBartConfig, MBartForConditionalGeneration




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE		)    ->       Union[str, Any]:
  lowercase__           =  [
      'encoder.version',
      'decoder.version',
      'model.encoder.version',
      'model.decoder.version',
      '_float_tensor',
      'decoder.output_projection.weight',
  ]
  for k in ignore_keys:
    state_dict.pop(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE		)    ->       Dict:
  lowercase__      ,   lowercase__           =  emb.weight.shape
  lowercase__           =  nn.Linear(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		,						bias=_SCREAMING_SNAKE_CASE		)
  lowercase__           =  emb.weight.data
  return lin_layer




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE="facebook/mbart-large-en-ro"		,						_SCREAMING_SNAKE_CASE=False		,						_SCREAMING_SNAKE_CASE=False		)    ->       str:
  lowercase__           =  torch.load(_SCREAMING_SNAKE_CASE		,						map_location='cpu'		)['model']
  remove_ignore_keys_(_SCREAMING_SNAKE_CASE		)
  lowercase__           =  state_dict['encoder.embed_tokens.weight'].shape[0]

  lowercase__           =  MBartConfig.from_pretrained(_SCREAMING_SNAKE_CASE		,						vocab_size=_SCREAMING_SNAKE_CASE		)
  if mbart_aa and finetuned:
    lowercase__           =  'relu'

  lowercase__           =  state_dict['decoder.embed_tokens.weight']
  lowercase__           =  MBartForConditionalGeneration(_SCREAMING_SNAKE_CASE		)
  model.model.load_state_dict(_SCREAMING_SNAKE_CASE		)

  if finetuned:
    lowercase__           =  make_linear_from_emb(model.model.shared		)

  return model


if __name__ == "__main__":
      lowercase_          =		argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          """fairseq_path""", type=str, help="""bart.large, bart.large.cnn or a path to a model.pt on local filesystem."""
      )
      parser.add_argument("""pytorch_dump_folder_path""", default=None, type=str, help="""Path to the output PyTorch model.""")
      parser.add_argument(
          """--hf_config""",
          default="""facebook/mbart-large-cc25""",
          type=str,
          help="""Which huggingface architecture to use: mbart-large""",
      )
      parser.add_argument("""--mbart_50""", action="""store_true""", help="""whether the model is mMART-50 checkpoint""")
      parser.add_argument("""--finetuned""", action="""store_true""", help="""whether the model is a fine-tuned checkpoint""")
      lowercase_          =		parser.parse_args()
      lowercase_          =		convert_fairseq_mbart_checkpoint_from_disk(
          args.fairseq_path, hf_config_path=args.hf_config, finetuned=args.finetuned, mbart_aa=args.mbart_aa
      )
      model.save_pretrained(args.pytorch_dump_folder_path)


