class_docstr: Measurement process that computes the probability of each computational basis state.
  
  Please refer to :func:`probs` for detailed documentation.
  
  Args:
      obs (Union[.Operator, .MeasurementValue]): The observable that is to be measured
          as part of the measurement process. Not all measurement processes require observables
          (for example ``Probability``); this argument is optional.
      wires (.Wires): The wires the measurement process applies to.
          This can only be specified if an observable was not provided.
      eigvals (array): A flat array representing the eigenvalues of the measurement.
          This can only be specified if an observable was not provided.
      id (str): custom label given to a measurement instance, can be useful for some applications
          where the instance has to be identified
class_docstr_tok: ["Measurement","process","that","computes","the","probability","of","each","computational","basis","state",".","Please","refer","to",":","func",":","`","probs","`","for","detailed","documentation",".","Args",":","obs","(","Union","[",".Operator",",",".MeasurementValue","]",")",":","The","observable","that","is","to","be","measured","as","part","of","the","measurement","process",".","Not","all","measurement","processes","require","observables","(","for","example","``","Probability","``",")",";","this","argument","is","optional",".","wires","(",".Wires",")",":","The","wires","the","measurement","process","applies","to",".","This","can","only","be","specified","if","an","observable","was","not","provided",".","eigvals","(","array",")",":","A","flat","array","representing","the","eigenvalues","of","the","measurement",".","This","can","only","be","specified","if","an","observable","was","not","provided",".","id","(","str",")",":","custom","label","given","to","a","measurement","instance",",","can","be","useful","for","some","applications","where","the","instance","has","to","be","identified"]
code: def process_state(self, state: Sequence[complex], wire_order: Wires):
      prob = qml.math.real(state) ** 2 + qml.math.imag(state) ** 2
      if self.wires == Wires([]):
          # no need to marginalize
          return prob
  
      # determine which subsystems are to be summed over
      inactive_wires = Wires.unique_wires([wire_order, self.wires])
  
      # translate to wire labels used by device
      wire_map = dict(zip(wire_order, range(len(wire_order))))
      mapped_wires = [wire_map[w] for w in self.wires]
      inactive_wires = [wire_map[w] for w in inactive_wires]
  
      # reshape the probability so that each axis corresponds to a wire
      num_device_wires = len(wire_order)
      shape = [2] * num_device_wires
      desired_axes = np.argsort(np.argsort(mapped_wires))
      flat_shape = (-1,)
      expected_size = 2**num_device_wires
      batch_size = qml.math.get_batch_size(
          prob, (expected_size,), expected_size
      )
      if batch_size is not None:
          # prob now is reshaped to have self.num_wires+1 axes in the case of broadcasting
          shape.insert(0, batch_size)
          inactive_wires = [idx + 1 for idx in inactive_wires]
          desired_axes = np.insert(desired_axes + 1, 0, 0)
          flat_shape = (batch_size, -1)
  
      prob = qml.math.reshape(prob, shape)
      # sum over all inactive wires
      prob = qml.math.sum(prob, axis=tuple(inactive_wires))
      # rearrange wires if necessary
      prob = qml.math.transpose(prob, desired_axes)
      # flatten and return probabilities
      return qml.math.reshape(prob, flat_shape)
  
file_path: pennylane/pennylane/measurements/probs.py
imports: from typing import Sequence, Tuple
  import numpy
  import pennylane
  from pennylane.wires import Wires
  from .measurements import Probability, SampleMeasurement, StateMeasurement
  from .mid_measure import MeasurementValue
label_desc: Use image node_id 5 for calling the ProbabilityMP obj's underlying member method code with example usage: obj.process_state(state, wire_order) and returns: qml, prob