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"]
docstr: Count the occurrences of sampled indices and convert them to relative
  counts in order to estimate their occurrence probability.
docstr_tok: ["Count","the","occurrences","of","sampled","indices","and","convert","them","to","relative","counts","in","order","to","estimate","their","occurrence","probability","."]
code: def _count_samples(indices, batch_size, dim):
      """Count the occurrences of sampled indices and convert them to relative
      counts in order to estimate their occurrence probability."""
      num_bins, bin_size = indices.shape[-2:]
      if batch_size is None:
          prob = qml.math.zeros((dim, num_bins), dtype="float64")
          # count the basis state occurrences, and construct the probability vector for each bin
          for b, idx in enumerate(indices):
              basis_states, counts = qml.math.unique(
                  idx, return_counts=True
              )
              prob[basis_states, b] = counts / bin_size
  
          return prob
  
      prob = qml.math.zeros(
          (batch_size, dim, num_bins), dtype="float64"
      )
      indices = indices.reshape((batch_size, num_bins, bin_size))
  
      # count the basis state occurrences, and construct the probability vector
      # for each bin and broadcasting index
      for i, _indices in enumerate(
          indices
      ):  # First iterate over broadcasting dimension
          for b, idx in enumerate(
              _indices
          ):  # Then iterate over bins dimension
              basis_states, counts = qml.math.unique(
                  idx, return_counts=True
              )
              prob[i, basis_states, b] = counts / bin_size
  
      return prob
  
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 7 for calling the ProbabilityMP obj's underlying member method code with example usage: obj._count_samples(indices, batch_size, dim) and returns: prob, prob