class_docstr: Measurement process that returns the samples of a given observable. If no observable is
  provided then basis state samples are returned directly from the device.
  
  Please refer to :func:`sample` 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","returns","the","samples","of","a","given","observable",".","If","no","observable","is","provided","then","basis","state","samples","are","returned","directly","from","the","device",".","Please","refer","to",":","func",":","`","sample","`","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_samples(
      self,
      samples: Sequence[complex],
      wire_order: Wires,
      shot_range: Tuple[int] = None,
      bin_size: int = None,
  ):
      wire_map = dict(zip(wire_order, range(len(wire_order))))
      mapped_wires = [wire_map[w] for w in self.wires]
      name = self.obs.name if self.obs is not None else None
      # Select the samples from samples that correspond to ``shot_range`` if provided
      if shot_range is not None:
          # Indexing corresponds to: (potential broadcasting, shots, wires). Note that the last
          # colon (:) is required because shots is the second-to-last axis and the
          # Ellipsis (...) otherwise would take up broadcasting and shots axes.
          samples = samples[..., slice(*shot_range), :]
  
      if mapped_wires:
          # if wires are provided, then we only return samples from those wires
          samples = samples[..., mapped_wires]
  
      num_wires = samples.shape[-1]  # wires is the last dimension
  
      # If we're sampling wires or a list of mid-circuit measurements
      if self.obs is None and not isinstance(self.mv, MeasurementValue):
          # if no observable was provided then return the raw samples
          return (
              samples
              if bin_size is None
              else samples.T.reshape(num_wires, bin_size, -1)
          )
  
      # If we're sampling observables
      if str(name) in {"PauliX", "PauliY", "PauliZ", "Hadamard"}:
          # Process samples for observables with eigenvalues {1, -1}
          samples = 1 - 2 * qml.math.squeeze(samples, axis=-1)
      else:
          # Replace the basis state in the computational basis with the correct eigenvalue.
          # Extract only the columns of the basis samples required based on ``wires``.
          powers_of_two = 2 ** qml.math.arange(num_wires)[::-1]
          indices = samples @ powers_of_two
          indices = qml.math.array(
              indices
          )  # Add np.array here for Jax support.
          try:
              # This also covers statistics for mid-circuit measurements manipulated using
              # arithmetic operators
              samples = self.eigvals()[indices]
          except qml.operation.EigvalsUndefinedError as e:
              # if observable has no info on eigenvalues, we cannot return this measurement
              raise qml.operation.EigvalsUndefinedError(
                  f"Cannot compute samples of {self.obs.name}."
              ) from e
  
      return (
          samples
          if bin_size is None
          else samples.reshape((bin_size, -1))
      )
  
file_path: pennylane/pennylane/measurements/sample.py
imports: import functools
  import warnings
  from typing import Sequence, Tuple, Optional, Union
  import pennylane
  from pennylane.operation import Operator
  from pennylane.wires import Wires
  from .measurements import MeasurementShapeError, Sample, SampleMeasurement
  from .mid_measure import MeasurementValue
label_desc: Use image node_id 4 for calling the SampleMP obj's underlying member method code with example usage: obj.process_samples(samples, wire_order, shot_range, bin_size) and returns: unknown, unknown