---
title: CollectTemplateValues (latest version)
description: API reference for samplomatic.samplex.nodes.CollectTemplateValues in the latest version of samplomatic
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/samplomatic/auto/samplex-nodes-collect-template-values
---

# CollectTemplateValues

*class* `samplomatic.samplex.nodes.CollectTemplateValues(template_params_name: str, template_idxs: ndarray[tuple[int, int], dtype[int64]], register_name: str, register_type: VirtualType, subsystem_idxs: ndarray[tuple[int], dtype[int64]], synth: Synth)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/collect_template_values.py#L24-L136)

Bases: [`CollectionNode`](/docs/api/samplomatic/auto/samplex-nodes-collection-node "samplomatic.samplex.nodes.collection_node.CollectionNode")

Collects a register slice and writes corresponding template values to output.

**Parameters**

- **template\_params\_name** – The name of the output to write template parameters to.
- **template\_idxs** – An array of shape `(num_subsystems, num_params_per_subsystem)` specifying which entries of the entire template parameter value array to write to.
- **register\_name** – The name of the register to collect.
- **register\_type** – What kind of register type to collect.
- **subsystem\_idxs** – The slice of the register to collect.
- **synth** – A synth to take the product of register values and generate template parameter values.

**Raises**

- [**SamplexConstructionError**](/docs/api/samplomatic/auto/exceptions-samplex-construction-error "samplomatic.exceptions.SamplexConstructionError") – If `register_type` is not compatible with `synth`.
- [**SamplexConstructionError**](/docs/api/samplomatic/auto/exceptions-samplex-construction-error "samplomatic.exceptions.SamplexConstructionError") – If the second axis of `template_idxs` does not match [`Synth.num_params`](/docs/api/samplomatic/auto/synths-synth#num_params "samplomatic.synths.Synth.num_params"), or the first axis of `template_idxs` does not match the number of subsystems in each entry of `registers`.

**Attributes Summary**

|                                                                                                                                                      |                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [`num_subsystems`](#samplomatic.samplex.nodes.CollectTemplateValues.num_subsystems "samplomatic.samplex.nodes.CollectTemplateValues.num_subsystems") | The number of subsystems being collected.                                         |
| [`template_idxs`](#samplomatic.samplex.nodes.CollectTemplateValues.template_idxs "samplomatic.samplex.nodes.CollectTemplateValues.template_idxs")    | Specification of which entries of the template parameter value array to write to. |

**Methods Summary**

|                                                                                                                                                                                             |                                                                                  |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [`collect`](#samplomatic.samplex.nodes.CollectTemplateValues.collect "samplomatic.samplex.nodes.CollectTemplateValues.collect")(registers, outputs, rng)                                    | Collect.                                                                         |
| [`get_style`](#samplomatic.samplex.nodes.CollectTemplateValues.get_style "samplomatic.samplex.nodes.CollectTemplateValues.get_style")()                                                     | Return the style of this node when plotted.                                      |
| [`outputs_to`](#samplomatic.samplex.nodes.CollectTemplateValues.outputs_to "samplomatic.samplex.nodes.CollectTemplateValues.outputs_to")()                                                  | Return the set of names of outputs this node mutates.                            |
| [`reads_from`](#samplomatic.samplex.nodes.CollectTemplateValues.reads_from "samplomatic.samplex.nodes.CollectTemplateValues.reads_from")()                                                  | Return a manifest of which virtual register values this node needs to read from. |
| [`validate_and_update`](#samplomatic.samplex.nodes.CollectTemplateValues.validate_and_update "samplomatic.samplex.nodes.CollectTemplateValues.validate_and_update")(register\_descriptions) | Validate provided register descriptions are compatible, update with changes.     |

**Attributes Documentation**

### num\_subsystems

The number of subsystems being collected.

### template\_idxs

Specification of which entries of the template parameter value array to write to.

**Methods Documentation**

### collect

`collect(registers, outputs, rng)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/collect_template_values.py#L105-L115)

Collect.

**Parameters**

- **registers** – Registers to collect from.
- **outputs** – Where to output.
- **rng** – A randomness generator.

### get\_style

`get_style()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/collect_template_values.py#L128-L136)

Return the style of this node when plotted.

### outputs\_to

`outputs_to()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/collect_template_values.py#L89-L90)

Return the set of names of outputs this node mutates.

### reads\_from

`reads_from()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/collect_template_values.py#L92-L93)

Return a manifest of which virtual register values this node needs to read from.

### validate\_and\_update

`validate_and_update(register_descriptions)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/collect_template_values.py#L95-L103)

Validate provided register descriptions are compatible, update with changes.

This method can be used by a samplex to determine when a node execution order has well-defined dependencies before sampling begins.

**Parameters**

**register\_descriptions** – A map from existing register names to their size and type.
