




"""simple docstring"""



import unittest

from transformers import is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow


if is_flax_available():
      import optax
      from flax.training.common_utils import onehot

      from transformers import AutoTokenizer, FlaxMTaForConditionalGeneration
      from transformers.models.ta.modeling_flax_ta import shift_tokens_right




@require_torch
@require_sentencepiece
@require_tokenizers
@require_flax
class 	UpperCAmelCase_  (						unittest.TestCase							):




    @slow
    def 							__magic_name__							(    self						:       Any      )      ->							Optional[Any]:




     '''simple docstring'''

     A__       =				FlaxMTaForConditionalGeneration.from_pretrained("google/mt5-small"      )
     A__       =				AutoTokenizer.from_pretrained("google/mt5-small"      )

     A__       =				tokenizer("Hello there"	, return_tensors="np"      ).input_ids
     A__       =				tokenizer("Hi I am"	, return_tensors="np"      ).input_ids

     A__       =				shift_tokens_right(SCREAMING_SNAKE_CASE__	, model.config.pad_token_id	, model.config.decoder_start_token_id      )

     A__       =				model(SCREAMING_SNAKE_CASE__	, decoder_input_ids=SCREAMING_SNAKE_CASE__      ).logits
     A__       =				optax.softmax_cross_entropy(SCREAMING_SNAKE_CASE__	, onehot(SCREAMING_SNAKE_CASE__	, logits.shape[-1]      )      ).mean()

     A__       =				-(labels.shape[-1] * loss.item())

     A__       =				-84.9_127
     self.assertTrue(abs(mtf_score - EXPECTED_SCORE      ) < 1e-4      )












"""simple docstring"""
import qiskit



def      __lowerCamelCase   (							a_     :		int ,   a_     :		int							)			->      qiskit.result.counts.Counts:
      __SCREAMING_SNAKE_CASE   :Tuple						=  qiskit.Aer.get_backend('''aer_simulator'''							)

      # Create a Quantum Circuit acting on the q register
      __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  qiskit.QuantumCircuit(a_ ,   a_							)

      # Apply X (NOT) Gate to Qubits 0 & 1
      circuit.x(0							)
      circuit.x(1							)

      # Map the quantum measurement to the classical bits
      circuit.measure([0, 1] ,   [0, 1]							)

      # Execute the circuit on the qasm simulator
      __SCREAMING_SNAKE_CASE   :Tuple						=  qiskit.execute(a_ ,   a_ ,   shots=10_00							)

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


if __name__ == "__main__":
  lowerCamelCase_								=		single_qubit_measure(2, 2)
  print(f'Total count for various states are: {counts}')