



'''simple docstring'''





from manim import *






class        lowerCAmelCase_(				SCREAMING_SNAKE_CASE_     ):
  '''simple docstring'''




  def 							UpperCAmelCase_	(    self      )    ->		Tuple:
      lowerCAmelCase__ :  Dict							      =					Rectangle(height=0.5  ,width=0.5      )
      lowerCAmelCase__ :  Any							      =					Rectangle(height=0.2_5  ,width=0.2_5      )
      lowerCAmelCase__ :  List[str]							      =					Rectangle(height=0.4_6  ,width=0.4_6      ).set_stroke(width=0      )

      lowerCAmelCase__ :  Any							      =					[mem.copy() for i in range(6      )]
      lowerCAmelCase__ :  List[str]							      =					[mem.copy() for i in range(6      )]
      lowerCAmelCase__ :  str							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  Optional[Any]							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  List[Any]							      =					VGroup(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  Optional[Any]							      =					Text("""CPU"""  ,font_size=24      )
      lowerCAmelCase__ :  str							      =					Group(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0.5  ,aligned_edge=__UpperCAmelCase      )
      cpu.move_to([-2.5, -0.5, 0]      )
      self.add(__UpperCAmelCase      )

      lowerCAmelCase__ :  str							      =					[mem.copy() for i in range(4      )]
      lowerCAmelCase__ :  List[Any]							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  Optional[int]							      =					Text("""GPU"""  ,font_size=24      )
      lowerCAmelCase__ :  Union[str, Any]							      =					Group(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0.5  ,aligned_edge=__UpperCAmelCase      )
      gpu.move_to([-1, -1, 0]      )
      self.add(__UpperCAmelCase      )

      lowerCAmelCase__ :  Tuple							      =					[mem.copy() for i in range(6      )]
      lowerCAmelCase__ :  List[str]							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )

      lowerCAmelCase__ :  Optional[Any]							      =					Text("""Model"""  ,font_size=24      )
      lowerCAmelCase__ :  Optional[Any]							      =					Group(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0.5  ,aligned_edge=__UpperCAmelCase      )
      model.move_to([3, -1.0, 0]      )
      self.add(__UpperCAmelCase      )

      lowerCAmelCase__ :  Any							      =					[]
      lowerCAmelCase__ :  Any							      =					[]
      lowerCAmelCase__ :  List[Any]							      =					[]

      for i, rect in enumerate(__UpperCAmelCase      ):
          rect.set_stroke(__UpperCAmelCase      )

          lowerCAmelCase__ :  str							      =					Rectangle(height=0.4_6 / 4  ,width=0.4_6 / 3      ).set_stroke(width=0.0      ).set_fill(__UpperCAmelCase  ,opacity=0.7      )

          if i == 0:
              cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT      )  ,buff=0.0_2  ,direction=__UpperCAmelCase      )
              cpu_target.set_x(cpu_target.get_x() + 0.1      )
          elif i == 3:
              cpu_target.next_to(model_cpu_arr[0]  ,direction=__UpperCAmelCase  ,buff=0.0      )
          else:
              cpu_target.next_to(model_cpu_arr[i - 1]  ,direction=__UpperCAmelCase  ,buff=0.0      )
          self.add(__UpperCAmelCase      )
          model_cpu_arr.append(__UpperCAmelCase      )

      self.add(*__UpperCAmelCase  ,*__UpperCAmelCase  ,*__UpperCAmelCase      )

      lowerCAmelCase__ :  Dict							      =					[mem.copy() for i in range(6      )]
      lowerCAmelCase__ :  Any							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )

      lowerCAmelCase__ :  int							      =					Text("""Loaded Checkpoint"""  ,font_size=24      )
      lowerCAmelCase__ :  str							      =					Group(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0.5  ,aligned_edge=__UpperCAmelCase      )
      checkpoint.move_to([3, 0.5, 0]      )

      self.add(__UpperCAmelCase      )

      lowerCAmelCase__ :  List[str]							      =					[]
      lowerCAmelCase__ :  List[str]							      =					[]

      for i, rect in enumerate(__UpperCAmelCase      ):
          lowerCAmelCase__ :  List[Any]							      =					fill.copy().set_fill(__UpperCAmelCase  ,opacity=0.7      )
          target.move_to(__UpperCAmelCase      )
          ckpt_arr.append(__UpperCAmelCase      )

          lowerCAmelCase__ :  Optional[Any]							      =					target.copy()
          if i < 5:
              cpu_target.move_to(cpu_left_col_base[i + 1]      )
          else:
              cpu_target.move_to(cpu_right_col_base[i - 5]      )
          ckpt_cpu_arr.append(__UpperCAmelCase      )
      self.add(*__UpperCAmelCase  ,*__UpperCAmelCase      )

      lowerCAmelCase__ :  str							      =					Square(side_length=2.2      )
      key.move_to([-5, 2, 0]      )

      lowerCAmelCase__ :  Any							      =					MarkupText(
          F"""<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model"""  ,font_size=18  ,)

      key_text.move_to([-5, 2.4, 0]      )

      self.add(__UpperCAmelCase  ,__UpperCAmelCase      )

      lowerCAmelCase__ :  int							      =					MarkupText(
          F"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""  ,font_size=18  ,)

      blue_text.next_to(__UpperCAmelCase  ,DOWN * 2.4  ,aligned_edge=key_text.get_left()      )
      self.add(__UpperCAmelCase      )

      lowerCAmelCase__ :  str							      =					MarkupText(
          F"""Based on the passed in configuration, weights are stored in\na variety of np.memmaps on disk or to a particular device."""  ,font_size=24  ,)
      step_a.move_to([2, 2, 0]      )

      lowerCAmelCase__ :  List[Any]							      =					[meta_mem.copy() for i in range(6      )]
      lowerCAmelCase__ :  str							      =					[meta_mem.copy() for i in range(6      )]
      lowerCAmelCase__ :  Union[str, Any]							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  Dict							      =					VGroup(*__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  Union[str, Any]							      =					VGroup(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0      )
      lowerCAmelCase__ :  Tuple							      =					Text("""Disk"""  ,font_size=24      )
      lowerCAmelCase__ :  Optional[Any]							      =					Group(__UpperCAmelCase  ,__UpperCAmelCase      ).arrange(__UpperCAmelCase  ,buff=0.5  ,aligned_edge=__UpperCAmelCase      )
      disk.move_to([-4.0, -1.2_5, 0]      )
      self.play(Write(__UpperCAmelCase  ,run_time=3      )  ,Write(__UpperCAmelCase  ,run_time=1      )  ,Create(__UpperCAmelCase  ,run_time=1      )      )

      lowerCAmelCase__ :  List[Any]							      =					[]
      for i, rect in enumerate(__UpperCAmelCase      ):
          lowerCAmelCase__ :  Optional[int]							      =					rect.copy()
          target.generate_target()
          target.target.move_to(disk_left_col_base[i]      ).scale(0.5      )
          animations.append(MoveToTarget(__UpperCAmelCase  ,run_time=1.5      )      )
      self.play(*__UpperCAmelCase      )

      self.play(FadeOut(__UpperCAmelCase      )      )

      lowerCAmelCase__ :  Tuple							      =					MarkupText(F"""Then, the checkpoint is removed from memory\nthrough garbage collection."""  ,font_size=24      )
      step_a.move_to([2, 2, 0]      )

      self.play(Write(__UpperCAmelCase  ,run_time=3      )      )

      self.play(
          FadeOut(__UpperCAmelCase  ,__UpperCAmelCase  ,*__UpperCAmelCase  ,*__UpperCAmelCase      )  ,)

      self.wait()



import qiskit





def 				UpperCAmelCase						(    lowercase							,			lowercase							):







				"""simple docstring"""



				__lowercase 			=							qiskit.Aer.get_backend('''aer_simulator'''							)

				# Create a Quantum Circuit acting on the q register
				__lowercase 			=							qiskit.QuantumCircuit(lowercase							,			lowercase							)

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

				# Execute the circuit on the simulator
				__lowercase 			=							qiskit.execute(lowercase							,			lowercase							,			shots=1000							)

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


if __name__ == "__main__":
		print(F'''Total count for various states are: {single_qubit_measure(1, 1)}''')