class_docstr: The operations and measurements that represent instructions for
  execution on a quantum device.
  
  Args:
      ops (Iterable[Operator]): An iterable of the operations to be performed
      measurements (Iterable[MeasurementProcess]): All the measurements to be performed
  
  Keyword Args:
      shots (None, int, Sequence[int], ~.Shots): Number and/or batches of shots for execution.
          Note that this property is still experimental and under development.
      trainable_params (None, Sequence[int]): the indices for which parameters are trainable
      _update=True (bool): Whether or not to set various properties on initialization. Setting
          ``_update=False`` reduces computations if the script is only an intermediary step.
  
  .. seealso:: :class:`pennylane.tape.QuantumTape`
  
  **Example:**
  
  .. code-block:: python
  
      from pennylane.tape import QuantumScript
  
      ops = [qml.BasisState(np.array([1,1]), wires=(0,"a")),
             qml.RX(0.432, 0),
             qml.RY(0.543, 0),
             qml.CNOT((0,"a")),
             qml.RX(0.133, "a")]
  
      qscript = QuantumScript(ops, [qml.expval(qml.PauliZ(0))])
  
  >>> list(qscript)
  [BasisState(array([1, 1]), wires=[0, "a"]),
  RX(0.432, wires=[0]),
  RY(0.543, wires=[0]),
  CNOT(wires=[0, 'a']),
  RX(0.133, wires=['a']),
  expval(PauliZ(wires=[0]))]
  >>> qscript.operations
  [BasisState(array([1, 1]), wires=[0, "a"]),
  RX(0.432, wires=[0]),
  RY(0.543, wires=[0]),
  CNOT(wires=[0, 'a']),
  RX(0.133, wires=['a'])]
  >>> qscript.measurements
  [expval(PauliZ(wires=[0]))]
  
  Iterating over the quantum script can be done by:
  
  >>> for op in qscript:
  ...     print(op)
  BasisState(array([1, 1]), wires=[0, "a"])
  RX(0.432, wires=[0])
  RY(0.543, wires=[0])
  CNOT(wires=[0, 'a'])
  RX(0.133, wires=['a'])
  expval(PauliZ(wires=[0]))'
  
  Quantum scripts also support indexing and length determination:
  
  >>> qscript[0]
  BasisState(array([1, 1]), wires=[0, "a"])
  >>> len(qscript)
  6
  
  Once constructed, the script can be executed directly on a quantum device
  using the :func:`~.pennylane.execute` function:
  
  >>> dev = qml.device('default.qubit', wires=(0,'a'))
  >>> qml.execute([qscript], dev, gradient_fn=None)
  [array([-0.77750694])]
  
  Quantum scripts can also store information about the number and batches of
  executions by setting the ``shots`` keyword argument. This information is internally
  stored in a :class:`pennylane.measurements.Shots` object:
  
  >>> s_vec = [1, 1, 2, 2, 2]
  >>> qscript = QuantumScript([qml.Hadamard(0)], [qml.expval(qml.PauliZ(0))], shots=s_vec)
  >>> qscript.shots.shot_vector
  (ShotCopies(1 shots x 2), ShotCopies(2 shots x 3))
  
  ``ops`` and ``measurements`` are converted to lists upon initialization,
  so those arguments accept any iterable object:
  
  >>> qscript = QuantumScript((qml.PauliX(i) for i in range(3)))
  >>> qscript.circuit
  [PauliX(wires=[0]), PauliX(wires=[1]), PauliX(wires=[2])]
class_docstr_tok: ["The","operations","and","measurements","that","represent","instructions","for","execution","on","a","quantum","device",".","Args",":","ops","(","Iterable","[","Operator","]",")",":","An","iterable","of","the","operations","to","be","performed","measurements","(","Iterable","[","MeasurementProcess","]",")",":","All","the","measurements","to","be","performed","Keyword","Args",":","shots","(","None",",","int",",","Sequence","[","int","]",",","~.Shots",")",":","Number","and\/or","batches","of","shots","for","execution",".","Note","that","this","property","is","still","experimental","and","under","development",".","trainable_params","(","None",",","Sequence","[","int","]",")",":","the","indices","for","which","parameters","are","trainable","_update=True","(","bool",")",":","Whether","or","not","to","set","various","properties","on","initialization",".","Setting","``","_update=False","``","reduces","computations","if","the","script","is","only","an","intermediary","step",".","..","seealso",":",":",":","class",":","`","pennylane.tape.QuantumTape","`","*","*","Example",":","*","*","..","code-block",":",":","python","from","pennylane.tape","import","QuantumScript","ops","=","[","qml.BasisState","(","np.array","(","[","1,1","]",")",",","wires=","(","0",",","''","a","''",")",")",",","qml.RX","(","0.432",",","0",")",",","qml.RY","(","0.543",",","0",")",",","qml.CNOT","(","(","0",",","''","a","''",")",")",",","qml.RX","(","0.133",",","``","a","''",")","]","qscript","=","QuantumScript","(","ops",",","[","qml.expval","(","qml.PauliZ","(","0",")",")","]",")",">",">",">","list","(","qscript",")","[","BasisState","(","array","(","[","1",",","1","]",")",",","wires=","[","0",",","``","a","''","]",")",",","RX","(","0.432",",","wires=","[","0","]",")",",","RY","(","0.543",",","wires=","[","0","]",")",",","CNOT","(","wires=","[","0",",","'","a","'","]",")",",","RX","(","0.133",",","wires=","[","'","a","'","]",")",",","expval","(","PauliZ","(","wires=","[","0","]",")",")","]",">",">",">","qscript.operations","[","BasisState","(","array","(","[","1",",","1","]",")",",","wires=","[","0",",","``","a","''","]",")",",","RX","(","0.432",",","wires=","[","0","]",")",",","RY","(","0.543",",","wires=","[","0","]",")",",","CNOT","(","wires=","[","0",",","'","a","'","]",")",",","RX","(","0.133",",","wires=","[","'","a","'","]",")","]",">",">",">","qscript.measurements","[","expval","(","PauliZ","(","wires=","[","0","]",")",")","]","Iterating","over","the","quantum","script","can","be","done","by",":",">",">",">","for","op","in","qscript",":","...","print","(","op",")","BasisState","(","array","(","[","1",",","1","]",")",",","wires=","[","0",",","``","a","''","]",")","RX","(","0.432",",","wires=","[","0","]",")","RY","(","0.543",",","wires=","[","0","]",")","CNOT","(","wires=","[","0",",","'","a","'","]",")","RX","(","0.133",",","wires=","[","'","a","'","]",")","expval","(","PauliZ","(","wires=","[","0","]",")",")","'","Quantum","scripts","also","support","indexing","and","length","determination",":",">",">",">","qscript","[","0","]","BasisState","(","array","(","[","1",",","1","]",")",",","wires=","[","0",",","``","a","''","]",")",">",">",">","len","(","qscript",")","6","Once","constructed",",","the","script","can","be","executed","directly","on","a","quantum","device","using","the",":","func",":","`","~.pennylane.execute","`","function",":",">",">",">","dev","=","qml.device","(","'default.qubit","'",",","wires=","(","0",",","'","a","'",")",")",">",">",">","qml.execute","(","[","qscript","]",",","dev",",","gradient_fn=None",")","[","array","(","[","-0.77750694","]",")","]","Quantum","scripts","can","also","store","information","about","the","number","and","batches","of","executions","by","setting","the","``","shots","``","keyword","argument",".","This","information","is","internally","stored","in","a",":","class",":","`","pennylane.measurements.Shots","`","object",":",">",">",">","s_vec","=","[","1",",","1",",","2",",","2",",","2","]",">",">",">","qscript","=","QuantumScript","(","[","qml.Hadamard","(","0",")","]",",","[","qml.expval","(","qml.PauliZ","(","0",")",")","]",",","shots=s_vec",")",">",">",">","qscript.shots.shot_vector","(","ShotCopies","(","1","shots","x","2",")",",","ShotCopies","(","2","shots","x","3",")",")","``","ops","``","and","``","measurements","``","are","converted","to","lists","upon","initialization",",","so","those","arguments","accept","any","iterable","object",":",">",">",">","qscript","=","QuantumScript","(","(","qml.PauliX","(","i",")","for","i","in","range","(","3",")",")",")",">",">",">","qscript.circuit","[","PauliX","(","wires=","[","0","]",")",",","PauliX","(","wires=","[","1","]",")",",","PauliX","(","wires=","[","2","]",")","]"]
docstr: Create a new tape with updated parameters.
  
  This function takes a list of new parameters as input, and returns
  a new :class:`~.tape.QuantumScript` containing the new parameters at the provided indices,
  with the parameters at all other indices remaining the same.
  
  Args:
      params (Sequence[TensorLike]): New parameters to create the tape with. This
          must have the same length as ``indices``.
      indices (Sequence[int]): The parameter indices to update with the given parameters.
          The index of a parameter is defined as its index in ``tape.get_parameters()``.
  
  Returns:
      .tape.QuantumScript: New tape with updated parameters
  
  **Example**
  
  >>> ops = [qml.RX(0.432, 0), qml.RY(0.543, 0),
  ...        qml.CNOT((0,"a")), qml.RX(0.133, "a")]
  >>> qscript = QuantumScript(ops, [qml.expval(qml.PauliZ(0))])
  
  A new tape can be created by passing new parameters along with the indices
  to be updated. To modify all parameters in the above qscript:
  
  >>> new_qscript = qscript.bind_new_parameters([0.1, 0.2, 0.3], [0, 1, 2])
  >>> new_qscript.get_parameters()
  [0.1, 0.2, 0.3]
  
  The original ``qscript`` remains unchanged:
  
  >>> qscript.get_parameters()
  [0.432, 0.543, 0.133]
  
  A subset of parameters can be modified as well, defined by the parameter indices:
  
  >>> newer_qscript = new_qscript.bind_new_parameters([-0.1, 0.5], [0, 2])
  >>> newer_qscript.get_parameters()
  [-0.1, 0.2, 0.5]
code: def bind_new_parameters(
      self, params: Sequence[TensorLike], indices: Sequence[int]
  ):
      """Create a new tape with updated parameters.
  
      This function takes a list of new parameters as input, and returns
      a new :class:`~.tape.QuantumScript` containing the new parameters at the provided indices,
      with the parameters at all other indices remaining the same.
  
      Args:
          params (Sequence[TensorLike]): New parameters to create the tape with. This
              must have the same length as ``indices``.
          indices (Sequence[int]): The parameter indices to update with the given parameters.
              The index of a parameter is defined as its index in ``tape.get_parameters()``.
  
      Returns:
          .tape.QuantumScript: New tape with updated parameters
  
      **Example**
  
      >>> ops = [qml.RX(0.432, 0), qml.RY(0.543, 0),
      ...        qml.CNOT((0,"a")), qml.RX(0.133, "a")]
      >>> qscript = QuantumScript(ops, [qml.expval(qml.PauliZ(0))])
  
      A new tape can be created by passing new parameters along with the indices
      to be updated. To modify all parameters in the above qscript:
  
      >>> new_qscript = qscript.bind_new_parameters([0.1, 0.2, 0.3], [0, 1, 2])
      >>> new_qscript.get_parameters()
      [0.1, 0.2, 0.3]
  
      The original ``qscript`` remains unchanged:
  
      >>> qscript.get_parameters()
      [0.432, 0.543, 0.133]
  
      A subset of parameters can be modified as well, defined by the parameter indices:
  
      >>> newer_qscript = new_qscript.bind_new_parameters([-0.1, 0.5], [0, 2])
      >>> newer_qscript.get_parameters()
      [-0.1, 0.2, 0.5]
      """
      # pylint: disable=no-member
  
      if len(params) != len(indices):
          raise ValueError(
              "Number of provided parameters does not match number of indices"
          )
  
      # determine the ops that need to be updated
      op_indices = {}
      for param_idx, idx in enumerate(sorted(indices)):
          pinfo = self._par_info[idx]
          op_idx, p_idx = pinfo["op_idx"], pinfo["p_idx"]
  
          if op_idx not in op_indices:
              op_indices[op_idx] = {}
  
          op_indices[op_idx][p_idx] = param_idx
  
      new_ops = self.circuit
  
      for op_idx, p_indices in op_indices.items():
          op = new_ops[op_idx]
          data = op.data if isinstance(op, Operator) else op.obs.data
  
          new_params = [
              params[p_indices[i]] if i in p_indices else d
              for i, d in enumerate(data)
          ]
  
          if isinstance(op, Operator):
              new_op = qml.ops.functions.bind_new_parameters(
                  op, new_params
              )
          else:
              new_obs = qml.ops.functions.bind_new_parameters(
                  op.obs, new_params
              )
              new_op = op.__class__(obs=new_obs)
  
          new_ops[op_idx] = new_op
  
      new_operations = new_ops[: len(self.operations)]
      new_measurements = new_ops[len(self.operations) :]
  
      return self.__class__(
          new_operations,
          new_measurements,
          shots=self.shots,
          trainable_params=self.trainable_params,
      )
  
imports: import contextlib
  import copy
  from collections import Counter
  from typing import List, Union, Optional, Sequence
  from warnings import warn
  import pennylane
  from pennylane.measurements import ClassicalShadowMP, CountsMP, MeasurementProcess, ProbabilityMP, SampleMP, ShadowExpvalMP, StateMP, Shots
  from pennylane.typing import TensorLike
  from pennylane.operation import Observable, Operator, Operation, _UNSET_BATCH_SIZE
  from pennylane.pytrees import register_pytree
  from pennylane.queuing import AnnotatedQueue, process_queue
  from pennylane.wires import Wires
label_desc: Use image node_id 35 for calling the QuantumScript obj's underlying member method code with example usage: obj.bind_new_parameters(params, indices) and returns: self