code: def measure_final_state(
      circuit, state, is_state_batched, rng=None, prng_key=None
  ) -> Result:
      """
      Perform the measurements required by the circuit on the provided state.
  
      This is an internal function that will be called by the successor to ``default.qubit``.
  
      Args:
          circuit (.QuantumScript): The single circuit to simulate
          state (TensorLike): The state to perform measurement on
          is_state_batched (bool): Whether the state has a batch dimension or not.
          rng (Union[None, int, array_like[int], SeedSequence, BitGenerator, Generator]): A
              seed-like parameter matching that of ``seed`` for ``numpy.random.default_rng``.
              If no value is provided, a default RNG will be used.
          prng_key (Optional[jax.random.PRNGKey]): An optional ``jax.random.PRNGKey``. This is
              the key to the JAX pseudo random number generator. Only for simulation using JAX.
              If None, the default ``sample_state`` function and a ``numpy.random.default_rng``
              will be for sampling.
  
      Returns:
          Tuple[TensorLike]: The measurement results
      """
  
      circuit = circuit.map_to_standard_wires()
  
      if not circuit.shots:
          # analytic case
  
          if len(circuit.measurements) == 1:
              return measure(
                  circuit.measurements[0],
                  state,
                  is_state_batched=is_state_batched,
              )
  
          return tuple(
              measure(mp, state, is_state_batched=is_state_batched)
              for mp in circuit.measurements
          )
  
      # finite-shot case
  
      rng = default_rng(rng)
      results = measure_with_samples(
          circuit.measurements,
          state,
          shots=circuit.shots,
          is_state_batched=is_state_batched,
          rng=rng,
          prng_key=prng_key,
      )
  
      if len(circuit.measurements) == 1:
          if circuit.shots.has_partitioned_shots:
              return tuple(res[0] for res in results)
  
          return results[0]
  
      return results
  
file_path: pennylane/pennylane/devices/qubit/simulate.py
imports: from typing import Optional
  from numpy.random import default_rng
  import numpy
  import pennylane
  from pennylane.typing import Result
  from .initialize_state import create_initial_state
  from .apply_operation import apply_operation
  from .measure import measure
  from .sampling import measure_with_samples
label_desc: Use image node_id 3 for calling a global function with example usage: measure_final_state(circuit, state, is_state_batched, rng, prng_key) and returns: results, tuple, results, measure, tuple