---
title: TwirlSamplingNode (latest version)
description: API reference for samplomatic.samplex.nodes.TwirlSamplingNode in the latest version of samplomatic
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/samplomatic/auto/samplex-nodes-twirl-sampling-node
---

# TwirlSamplingNode

*class* `samplomatic.samplex.nodes.TwirlSamplingNode(lhs_register_name: str, rhs_register_name: str, distribution: Distribution)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/twirl_sampling_node.py#L21-L71)

Bases: [`SamplingNode`](/docs/api/samplomatic/auto/samplex-nodes-sampling-node "samplomatic.samplex.nodes.sampling_node.SamplingNode")

A node that produces samples for twirling.

**Parameters**

- **lhs\_register\_name** – The name of the register to store the samples.
- **rhs\_register\_name** – The name of the register to store the inverses of the samples.
- **distribution** – The distribution to draw samples from.

**Attributes Summary**

|                                                                                                                                                                      |                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| [`outgoing_register_type`](#samplomatic.samplex.nodes.TwirlSamplingNode.outgoing_register_type "samplomatic.samplex.nodes.TwirlSamplingNode.outgoing_register_type") | The virtual gate type of outgoing registers. |

**Methods Summary**

|                                                                                                                                                   |                                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`get_style`](#samplomatic.samplex.nodes.TwirlSamplingNode.get_style "samplomatic.samplex.nodes.TwirlSamplingNode.get_style")()                   | Return the style of this node when plotted.                             |
| [`instantiates`](#samplomatic.samplex.nodes.TwirlSamplingNode.instantiates "samplomatic.samplex.nodes.TwirlSamplingNode.instantiates")()          | Return a manifest of new virtual registers that this node instantiates. |
| [`sample`](#samplomatic.samplex.nodes.TwirlSamplingNode.sample "samplomatic.samplex.nodes.TwirlSamplingNode.sample")(registers, rng, inputs, ...) | Sample this node.                                                       |

**Attributes Documentation**

### outgoing\_register\_type

**Methods Documentation**

### get\_style

`get_style()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/twirl_sampling_node.py#L64-L71)

Return the style of this node when plotted.

### instantiates

`instantiates() → dict[str, tuple[int, VirtualType]]`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/twirl_sampling_node.py#L44-L49)

Return a manifest of new virtual registers that this node instantiates.

> **Note**
>
> - To change the type or size of a register, both instantiate and remove it.
> - Do not specify `reads_from()` or `writes_to()` for an instantiated register, these powers are implicit.

### sample

`sample(registers, rng, inputs, num_randomizations)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/samplex/nodes/twirl_sampling_node.py#L51-L54)

Sample this node.

**Parameters**

- **registers** – Where to sample into.
- **rng** – A randomness generator.
- **inputs** – Inputs of the sampling program.
- **num\_randomizations** – How many randomizations to draw.
