class_docstr: Class for classical shadow post-processing expectation values, approximate states, and entropies.
  
  A ``ClassicalShadow`` is a classical description of a quantum state that is capable of reproducing expectation values of local Pauli observables, see `2002.08953 <https://arxiv.org/abs/2002.08953>`_.
  
  The idea is to capture :math:`T` local snapshots (given by the ``shots`` set in the device) of the state by performing measurements in random Pauli bases at each qubit.
  The measurement outcomes, denoted ``bits``, as well as the choices of measurement bases, ``recipes``, are recorded in two ``(T, len(wires))`` integer tensors, respectively.
  
  From the :math:`t`-th measurement, we can reconstruct the ``local_snapshots`` (see methods)
  
  .. math:: \rho^{(t)} = \bigotimes_{i=1}^{n} 3 U^\dagger_i |b_i \rangle \langle b_i | U_i - \mathbb{I},
  
  where :math:`U_i` is the rotation corresponding to the measurement (e.g. :math:`U_i=H` for measurement in :math:`X`) of qubit :math:`i` at snapshot :math:`t` and :math:`|b_i\rangle = (1 - b_i, b_i)`
  the corresponding computational basis state given the output bit :math:`b_i`.
  
  From these local snapshots, one can compute expectation values of local Pauli strings, where locality refers to the number of non-Identity operators.
  The accuracy of the procedure is determined by the number of measurements :math:`T` (``shots``).
  To target an error :math:`\epsilon`, one needs of order :math:`T = \mathcal{O}\left( \log(M) 4^\ell/\epsilon^2 \right)` measurements to determine :math:`M` different,
  :math:`\ell`-local observables.
  
  One can in principle also reconstruct the global state :math:`\sum_t \rho^{(t)}/T`, though it is not advisable nor practical for larger systems due to its exponential scaling.
  
  .. note:: As per `arXiv:2103.07510 <https://arxiv.org/abs/2103.07510>`_, when computing multiple expectation values it is advisable to directly estimate the desired observables by simultaneously measuring
      qubit-wise-commuting terms. One way of doing this in PennyLane is via :class:`~pennylane.Hamiltonian` and setting ``grouping_type="qwc"``. For more details on this topic, see our demo
      on `estimating expectation values with classical shadows <https://pennylane.ai/qml/demos/tutorial_diffable_shadows.html>`_.
  
  Args:
      bits (tensor): recorded measurement outcomes in random Pauli bases.
      recipes (tensor): recorded measurement bases.
      wire_map (list[int]): list of the measured wires in the order that
          they appear in the columns of ``bits`` and ``recipes``. If None, defaults
          to ``range(n)``, where ``n`` is the number of measured wires.
  
  .. seealso:: Demo on `Estimating observables with classical shadows in the Pauli basis <https://pennylane.ai/qml/demos/tutorial_diffable_shadows.html>`_, :func:`~.pennylane.classical_shadow`
  
  **Example**
  
  We obtain the ``bits`` and ``recipes`` via :func:`~.pennylane.classical_shadow` measurement:
  
  .. code-block:: python3
  
      dev = qml.device("default.qubit", wires=range(2), shots=1000)
      @qml.qnode(dev)
      def qnode(x):
          qml.Hadamard(0)
          qml.CNOT((0,1))
          qml.RX(x, wires=0)
          return qml.classical_shadow(wires=range(2))
  
      bits, recipes = qnode(0)
      shadow = qml.ClassicalShadow(bits, recipes)
  
  After recording these ``T=1000`` quantum measurements, we can post-process the results to arbitrary local expectation values of Pauli strings.
  For example, we can compute the expectation value of a Pauli string
  
  >>> shadow.expval(qml.PauliX(0) @ qml.PauliX(1), k=1)
  array(0.972)
  
  or of a Hamiltonian:
  
  >>> H = qml.Hamiltonian([1., 1.], [qml.PauliZ(0) @ qml.PauliZ(1), qml.PauliX(0) @ qml.PauliX(1)])
  >>> shadow.expval(H, k=1)
  array(1.917)
  
  The parameter ``k`` is used to estimate the expectation values via the `median of means` algorithm (see `2002.08953 <https://arxiv.org/abs/2002.08953>`_). The case ``k=1`` corresponds to simply taking the mean
  value over all local snapshots. ``k>1`` corresponds to splitting the ``T`` local snapshots into ``k`` equal parts, and taking the median of their individual means. For the case of measuring only in the Pauli basis,
  there is no advantage expected from setting ``k>1``.
class_docstr_tok: ["Class","for","classical","shadow","post-processing","expectation","values",",","approximate","states",",","and","entropies",".","A","``","ClassicalShadow","``","is","a","classical","description","of","a","quantum","state","that","is","capable","of","reproducing","expectation","values","of","local","Pauli","observables",",","see","`","2002.08953","<","https",":","\/\/arxiv.org\/abs\/2002.08953",">","`","_",".","The","idea","is","to","capture",":","math",":","`","T","`","local","snapshots","(","given","by","the","``","shots","``","set","in","the","device",")","of","the","state","by","performing","measurements","in","random","Pauli","bases","at","each","qubit",".","The","measurement","outcomes",",","denoted","``","bits","``",",","as","well","as","the","choices","of","measurement","bases",",","``","recipes","``",",","are","recorded","in","two","``","(","T",",","len","(","wires",")",")","``","integer","tensors",",","respectively",".","From","the",":","math",":","`","t","`","-th","measurement",",","we","can","reconstruct","the","``","local_snapshots","``","(","see","methods",")","..","math",":",":","\\rho^","{","(","t",")","}","=","\\bigotimes_","{","i=1","}","^","{","n","}","3","U^\\dagger_i","|b_i","\\rangle","\\langle","b_i","|","U_i","-","\\mathbb","{","I","}",",","where",":","math",":","`","U_i","`","is","the","rotation","corresponding","to","the","measurement","(","e.g",".",":","math",":","`","U_i=H","`","for","measurement","in",":","math",":","`","X","`",")","of","qubit",":","math",":","`","i","`","at","snapshot",":","math",":","`","t","`","and",":","math",":","`","|b_i\\rangle","=","(","1","-","b_i",",","b_i",")","`","the","corresponding","computational","basis","state","given","the","output","bit",":","math",":","`","b_i","`",".","From","these","local","snapshots",",","one","can","compute","expectation","values","of","local","Pauli","strings",",","where","locality","refers","to","the","number","of","non-Identity","operators",".","The","accuracy","of","the","procedure","is","determined","by","the","number","of","measurements",":","math",":","`","T","`","(","``","shots","``",")",".","To","target","an","error",":","math",":","`","\\epsilon","`",",","one","needs","of","order",":","math",":","`","T","=","\\mathcal","{","O","}","\\left","(","\\log","(","M",")","4^\\ell\/\\epsilon^2","\\right",")","`","measurements","to","determine",":","math",":","`","M","`","different",",",":","math",":","`","\\ell","`","-local","observables",".","One","can","in","principle","also","reconstruct","the","global","state",":","math",":","`","\\sum_t","\\rho^","{","(","t",")","}","\/T","`",",","though","it","is","not","advisable","nor","practical","for","larger","systems","due","to","its","exponential","scaling",".","..","note",":",":","As","per","`","arXiv:2103.07510","<","https",":","\/\/arxiv.org\/abs\/2103.07510",">","`","_",",","when","computing","multiple","expectation","values","it","is","advisable","to","directly","estimate","the","desired","observables","by","simultaneously","measuring","qubit-wise-commuting","terms",".","One","way","of","doing","this","in","PennyLane","is","via",":","class",":","`","~pennylane.Hamiltonian","`","and","setting","``","grouping_type=","''","qwc","''","``",".","For","more","details","on","this","topic",",","see","our","demo","on","`","estimating","expectation","values","with","classical","shadows","<","https",":","\/\/pennylane.ai\/qml\/demos\/tutorial_diffable_shadows.html",">","`","_",".","Args",":","bits","(","tensor",")",":","recorded","measurement","outcomes","in","random","Pauli","bases",".","recipes","(","tensor",")",":","recorded","measurement","bases",".","wire_map","(","list","[","int","]",")",":","list","of","the","measured","wires","in","the","order","that","they","appear","in","the","columns","of","``","bits","``","and","``","recipes","``",".","If","None",",","defaults","to","``","range","(","n",")","``",",","where","``","n","``","is","the","number","of","measured","wires",".","..","seealso",":",":","Demo","on","`","Estimating","observables","with","classical","shadows","in","the","Pauli","basis","<","https",":","\/\/pennylane.ai\/qml\/demos\/tutorial_diffable_shadows.html",">","`","_",",",":","func",":","`","~.pennylane.classical_shadow","`","*","*","Example","*","*","We","obtain","the","``","bits","``","and","``","recipes","``","via",":","func",":","`","~.pennylane.classical_shadow","`","measurement",":","..","code-block",":",":","python3","dev","=","qml.device","(","``","default.qubit","''",",","wires=range","(","2",")",",","shots=1000",")","@","qml.qnode","(","dev",")","def","qnode","(","x",")",":","qml.Hadamard","(","0",")","qml.CNOT","(","(","0,1",")",")","qml.RX","(","x",",","wires=0",")","return","qml.classical_shadow","(","wires=range","(","2",")",")","bits",",","recipes","=","qnode","(","0",")","shadow","=","qml.ClassicalShadow","(","bits",",","recipes",")","After","recording","these","``","T=1000","``","quantum","measurements",",","we","can","post-process","the","results","to","arbitrary","local","expectation","values","of","Pauli","strings",".","For","example",",","we","can","compute","the","expectation","value","of","a","Pauli","string",">",">",">","shadow.expval","(","qml.PauliX","(","0",")","@","qml.PauliX","(","1",")",",","k=1",")","array","(","0.972",")","or","of","a","Hamiltonian",":",">",">",">","H","=","qml.Hamiltonian","(","[","1.",",","1",".","]",",","[","qml.PauliZ","(","0",")","@","qml.PauliZ","(","1",")",",","qml.PauliX","(","0",")","@","qml.PauliX","(","1",")","]",")",">",">",">","shadow.expval","(","H",",","k=1",")","array","(","1.917",")","The","parameter","``","k","``","is","used","to","estimate","the","expectation","values","via","the","`","median","of","means","`","algorithm","(","see","`","2002.08953","<","https",":","\/\/arxiv.org\/abs\/2002.08953",">","`","_",")",".","The","case","``","k=1","``","corresponds","to","simply","taking","the","mean","value","over","all","local","snapshots",".","``","k",">","1","``","corresponds","to","splitting","the","``","T","``","local","snapshots","into","``","k","``","equal","parts",",","and","taking","the","median","of","their","individual","means",".","For","the","case","of","measuring","only","in","the","Pauli","basis",",","there","is","no","advantage","expected","from","setting","``","k",">","1","``","."]
docstr: Compute entropies from classical shadow measurements.
  
  Compute general Renyi entropies of order :math:`\alpha` for a reduced density matrix :math:`\rho` in terms of
  
  .. math:: S_\alpha(\rho) = \frac{1}{1-\alpha} \log\left(\text{tr}\left[\rho^\alpha \right] \right).
  
  There are two interesting special cases: In the limit :math:`\alpha \rightarrow 1`, we find the von Neumann entropy
  
  .. math:: S_{\alpha=1}(\rho) = -\text{tr}(\rho \log(\rho)).
  
  In the case of :math:`\alpha = 2`, the Renyi entropy becomes the logarithm of the purity of the reduced state
  
  .. math:: S_{\alpha=2}(\rho) = - \log\left(\text{tr}(\rho^2) \right).
  
  Since density matrices reconstructed from classical shadows can have negative eigenvalues, we use the algorithm described in
  `1106.5458 <https://arxiv.org/abs/1106.5458>`_ to project the estimator to the closest valid state.
  
  .. warning::
  
      Entropies are non-linear functions of the quantum state. Accuracy bounds on entropies with classical shadows are not known exactly,
      but scale exponentially in the subsystem size. It is advisable to only compute entropies for small subsystems of a few qubits.
      Further, entropies as post-processed by this class method are currently not automatically differentiable.
  
  Args:
      wires (Iterable[int]): The wires over which to compute the entropy of their reduced state. Note that the computation scales exponentially in the
          number of wires for the reduced state.
      snapshots (Iterable[int] or int): Only compute a subset of local snapshots. For ``snapshots=None`` (default), all local snapshots are taken.
          In case of an integer, a random subset of that size is taken. The subset can also be explicitly fixed by passing an Iterable with the corresponding indices.
      alpha (float): order of the Renyi-entropy. Defaults to ``alpha=2``, which corresponds to the purity of the reduced state. This case is straight forward to compute.
          All other cases ``alpha!=2`` necessitate computing the eigenvalues of the reduced state and thus may lead to longer computations times.
          Another special case is ``alpha=1``, which corresponds to the von Neumann entropy.
      k (int): Allow to split the snapshots into ``k`` equal parts and estimate the snapshots in a median of means fashion. There is no known advantage to do this for entropies.
          Thus, ``k=1`` is default and advised.
      base (float): Base to the logarithm used for the entropies.
  
  Returns:
      float: Entropy of the chosen subsystem.
  
  **Example**
  
  For the maximally entangled state of ``n`` qubits, the reduced state has two constant eigenvalues :math:`\frac{1}{2}`. For constant distributions, all Renyi entropies are
  equivalent:
  
  .. code-block:: python3
  
      wires = 4
      dev = qml.device("default.qubit", wires=range(wires), shots=1000)
  
      @qml.qnode(dev)
      def max_entangled_circuit():
          qml.Hadamard(wires=0)
          for i in range(1, wires):
              qml.CNOT(wires=[0, i])
          return qml.classical_shadow(wires=range(wires))
  
      bits, recipes = max_entangled_circuit()
      shadow = qml.ClassicalShadow(bits, recipes)
  
      entropies = [shadow.entropy(wires=[0], alpha=alpha) for alpha in [1., 2., 3.]]
  
  >>> np.isclose(entropies, entropies[0], atol=1e-2)
  [ True,  True,  True]
  
  For non-uniform reduced states that is not the case anymore and the entropy differs for each order ``alpha``:
  
  .. code-block:: python3
  
      @qml.qnode(dev)
      def qnode(x):
          for i in range(wires):
              qml.RY(x[i], wires=i)
  
          for i in range(wires - 1):
              qml.CNOT((i, i + 1))
  
          return qml.classical_shadow(wires=range(wires))
  
      x = np.linspace(0.5, 1.5, num=wires)
      bitstrings, recipes = qnode(x)
      shadow = qml.ClassicalShadow(bitstrings, recipes)
  
  >>> [shadow.entropy(wires=wires, alpha=alpha) for alpha in [1., 2., 3.]]
  [1.5419292874423107, 1.1537924276625828, 0.9593638767763727]
docstr_tok: ["Compute","entropies","from","classical","shadow","measurements",".","Compute","general","Renyi","entropies","of","order",":","math",":","`","\\alpha","`","for","a","reduced","density","matrix",":","math",":","`","\\rho","`","in","terms","of","..","math",":",":","S_\\alpha","(","\\rho",")","=","\\frac","{","1","}","{","1-\\alpha","}","\\log\\left","(","\\text","{","tr","}","\\left","[","\\rho^\\alpha","\\right","]","\\right",")",".","There","are","two","interesting","special","cases",":","In","the","limit",":","math",":","`","\\alpha","\\rightarrow","1","`",",","we","find","the","von","Neumann","entropy","..","math",":",":","S_","{","\\alpha=1","}","(","\\rho",")","=","-\\text","{","tr","}","(","\\rho","\\log","(","\\rho",")",")",".","In","the","case","of",":","math",":","`","\\alpha","=","2","`",",","the","Renyi","entropy","becomes","the","logarithm","of","the","purity","of","the","reduced","state","..","math",":",":","S_","{","\\alpha=2","}","(","\\rho",")","=","-","\\log\\left","(","\\text","{","tr","}","(","\\rho^2",")","\\right",")",".","Since","density","matrices","reconstructed","from","classical","shadows","can","have","negative","eigenvalues",",","we","use","the","algorithm","described","in","`","1106.5458","<","https",":","\/\/arxiv.org\/abs\/1106.5458",">","`","_","to","project","the","estimator","to","the","closest","valid","state",".","..","warning",":",":","Entropies","are","non-linear","functions","of","the","quantum","state",".","Accuracy","bounds","on","entropies","with","classical","shadows","are","not","known","exactly",",","but","scale","exponentially","in","the","subsystem","size",".","It","is","advisable","to","only","compute","entropies","for","small","subsystems","of","a","few","qubits",".","Further",",","entropies","as","post-processed","by","this","class","method","are","currently","not","automatically","differentiable",".","Args",":","wires","(","Iterable","[","int","]",")",":","The","wires","over","which","to","compute","the","entropy","of","their","reduced","state",".","Note","that","the","computation","scales","exponentially","in","the","number","of","wires","for","the","reduced","state",".","snapshots","(","Iterable","[","int","]","or","int",")",":","Only","compute","a","subset","of","local","snapshots",".","For","``","snapshots=None","``","(","default",")",",","all","local","snapshots","are","taken",".","In","case","of","an","integer",",","a","random","subset","of","that","size","is","taken",".","The","subset","can","also","be","explicitly","fixed","by","passing","an","Iterable","with","the","corresponding","indices",".","alpha","(","float",")",":","order","of","the","Renyi-entropy",".","Defaults","to","``","alpha=2","``",",","which","corresponds","to","the","purity","of","the","reduced","state",".","This","case","is","straight","forward","to","compute",".","All","other","cases","``","alpha","!","=2","``","necessitate","computing","the","eigenvalues","of","the","reduced","state","and","thus","may","lead","to","longer","computations","times",".","Another","special","case","is","``","alpha=1","``",",","which","corresponds","to","the","von","Neumann","entropy",".","k","(","int",")",":","Allow","to","split","the","snapshots","into","``","k","``","equal","parts","and","estimate","the","snapshots","in","a","median","of","means","fashion",".","There","is","no","known","advantage","to","do","this","for","entropies",".","Thus",",","``","k=1","``","is","default","and","advised",".","base","(","float",")",":","Base","to","the","logarithm","used","for","the","entropies",".","Returns",":","float",":","Entropy","of","the","chosen","subsystem",".","*","*","Example","*","*","For","the","maximally","entangled","state","of","``","n","``","qubits",",","the","reduced","state","has","two","constant","eigenvalues",":","math",":","`","\\frac","{","1","}","{","2","}","`",".","For","constant","distributions",",","all","Renyi","entropies","are","equivalent",":","..","code-block",":",":","python3","wires","=","4","dev","=","qml.device","(","``","default.qubit","''",",","wires=range","(","wires",")",",","shots=1000",")","@","qml.qnode","(","dev",")","def","max_entangled_circuit","(",")",":","qml.Hadamard","(","wires=0",")","for","i","in","range","(","1",",","wires",")",":","qml.CNOT","(","wires=","[","0",",","i","]",")","return","qml.classical_shadow","(","wires=range","(","wires",")",")","bits",",","recipes","=","max_entangled_circuit","(",")","shadow","=","qml.ClassicalShadow","(","bits",",","recipes",")","entropies","=","[","shadow.entropy","(","wires=","[","0","]",",","alpha=alpha",")","for","alpha","in","[","1.",",","2.",",","3",".","]","]",">",">",">","np.isclose","(","entropies",",","entropies","[","0","]",",","atol=1e-2",")","[","True",",","True",",","True","]","For","non-uniform","reduced","states","that","is","not","the","case","anymore","and","the","entropy","differs","for","each","order","``","alpha","``",":","..","code-block",":",":","python3","@","qml.qnode","(","dev",")","def","qnode","(","x",")",":","for","i","in","range","(","wires",")",":","qml.RY","(","x","[","i","]",",","wires=i",")","for","i","in","range","(","wires","-","1",")",":","qml.CNOT","(","(","i",",","i","+","1",")",")","return","qml.classical_shadow","(","wires=range","(","wires",")",")","x","=","np.linspace","(","0.5",",","1.5",",","num=wires",")","bitstrings",",","recipes","=","qnode","(","x",")","shadow","=","qml.ClassicalShadow","(","bitstrings",",","recipes",")",">",">",">","[","shadow.entropy","(","wires=wires",",","alpha=alpha",")","for","alpha","in","[","1.",",","2.",",","3",".","]","]","[","1.5419292874423107",",","1.1537924276625828",",","0.9593638767763727","]"]
code: def entropy(self, wires, snapshots=None, alpha=2, k=1, base=None):
      r"""Compute entropies from classical shadow measurements.
  
      Compute general Renyi entropies of order :math:`\alpha` for a reduced density matrix :math:`\rho` in terms of
  
      .. math:: S_\alpha(\rho) = \frac{1}{1-\alpha} \log\left(\text{tr}\left[\rho^\alpha \right] \right).
  
      There are two interesting special cases: In the limit :math:`\alpha \rightarrow 1`, we find the von Neumann entropy
  
      .. math:: S_{\alpha=1}(\rho) = -\text{tr}(\rho \log(\rho)).
  
      In the case of :math:`\alpha = 2`, the Renyi entropy becomes the logarithm of the purity of the reduced state
  
      .. math:: S_{\alpha=2}(\rho) = - \log\left(\text{tr}(\rho^2) \right).
  
      Since density matrices reconstructed from classical shadows can have negative eigenvalues, we use the algorithm described in
      `1106.5458 <https://arxiv.org/abs/1106.5458>`_ to project the estimator to the closest valid state.
  
      .. warning::
  
          Entropies are non-linear functions of the quantum state. Accuracy bounds on entropies with classical shadows are not known exactly,
          but scale exponentially in the subsystem size. It is advisable to only compute entropies for small subsystems of a few qubits.
          Further, entropies as post-processed by this class method are currently not automatically differentiable.
  
      Args:
          wires (Iterable[int]): The wires over which to compute the entropy of their reduced state. Note that the computation scales exponentially in the
              number of wires for the reduced state.
          snapshots (Iterable[int] or int): Only compute a subset of local snapshots. For ``snapshots=None`` (default), all local snapshots are taken.
              In case of an integer, a random subset of that size is taken. The subset can also be explicitly fixed by passing an Iterable with the corresponding indices.
          alpha (float): order of the Renyi-entropy. Defaults to ``alpha=2``, which corresponds to the purity of the reduced state. This case is straight forward to compute.
              All other cases ``alpha!=2`` necessitate computing the eigenvalues of the reduced state and thus may lead to longer computations times.
              Another special case is ``alpha=1``, which corresponds to the von Neumann entropy.
          k (int): Allow to split the snapshots into ``k`` equal parts and estimate the snapshots in a median of means fashion. There is no known advantage to do this for entropies.
              Thus, ``k=1`` is default and advised.
          base (float): Base to the logarithm used for the entropies.
  
      Returns:
          float: Entropy of the chosen subsystem.
  
      **Example**
  
      For the maximally entangled state of ``n`` qubits, the reduced state has two constant eigenvalues :math:`\frac{1}{2}`. For constant distributions, all Renyi entropies are
      equivalent:
  
      .. code-block:: python3
  
          wires = 4
          dev = qml.device("default.qubit", wires=range(wires), shots=1000)
  
          @qml.qnode(dev)
          def max_entangled_circuit():
              qml.Hadamard(wires=0)
              for i in range(1, wires):
                  qml.CNOT(wires=[0, i])
              return qml.classical_shadow(wires=range(wires))
  
          bits, recipes = max_entangled_circuit()
          shadow = qml.ClassicalShadow(bits, recipes)
  
          entropies = [shadow.entropy(wires=[0], alpha=alpha) for alpha in [1., 2., 3.]]
  
      >>> np.isclose(entropies, entropies[0], atol=1e-2)
      [ True,  True,  True]
  
      For non-uniform reduced states that is not the case anymore and the entropy differs for each order ``alpha``:
  
      .. code-block:: python3
  
          @qml.qnode(dev)
          def qnode(x):
              for i in range(wires):
                  qml.RY(x[i], wires=i)
  
              for i in range(wires - 1):
                  qml.CNOT((i, i + 1))
  
              return qml.classical_shadow(wires=range(wires))
  
          x = np.linspace(0.5, 1.5, num=wires)
          bitstrings, recipes = qnode(x)
          shadow = qml.ClassicalShadow(bitstrings, recipes)
  
      >>> [shadow.entropy(wires=wires, alpha=alpha) for alpha in [1., 2., 3.]]
      [1.5419292874423107, 1.1537924276625828, 0.9593638767763727]
  
      """
  
      global_snapshots = self.global_snapshots(
          wires=wires, snapshots=snapshots
      )
      rdm = median_of_means(global_snapshots, k, axis=0)
  
      # Allow for different log base
      div = np.log(base) if base else 1
  
      evs_nonzero = _project_density_matrix_spectrum(rdm)
      if alpha == 1:
          # Special case of von Neumann entropy
          return qml.math.entr(evs_nonzero) / div
  
      # General Renyi-alpha entropy
      return (
          qml.math.log(qml.math.sum(evs_nonzero**alpha))
          / (1.0 - alpha)
          / div
      )
  
file_path: pennylane/pennylane/shadows/classical_shadow.py
imports: import warnings
  from collections.abc import Iterable
  from string import ascii_letters
  import numpy
  import pennylane
label_desc: Use image node_id 7 for calling the ClassicalShadow obj's underlying member method code with example usage: obj.entropy(wires, snapshots, alpha, k, base) and returns: unknown, unknown