## If {#openvino_docs_ops_infrastructure_If_8}
**Versioned name**: *If-8*
**Category**: *Condition*
**Short description**: *If* operation contains two internal networks(subgraphs) such as `then_body` and `else_body`,
and performs one of them depending on `cond` value. If `cond` is `True`, `then_body` is executed. If `cond` is `False`,
the operation executes the `else_body` subgraph.
**Detailed description**
*If* must not contain empty subgraphs. Each of them must have at least one operation `Result`.
Also the number of outputs from *If* always must be greater than zero and equal to the number of outputs from each subgraph.
**If attributes**:
* **Subgraphs**:
`then_body`/`else_body` are subgraphs that are executed depending on the `cond` value.
The subgraph is described operation by operation as a typical IR network.
The subgraph has inputs (`Parameter` operations) and outputs (`Result` operations).
* **Subgraph's inputs** - inputs to the subgraph which associated with *If* inputs via *port_map*.
The subgraph can have any number of inputs (even zero).
* **Subgraph's outputs** - outputs from the subgraph which associated with *If* outputs via *port_map*.
The subgraph must contain at least one output. Each *If* output is associated with one output from the subgraph.
Therefore the number of `then_body` outputs is equal to the number of outputs from *If* and
the number of `else_body` outputs.
The type of the subgraph output and the type of the associated output from *If* must be equal.
* **Port maps**:
*port_map* is a set of rules to map input or output data tensors of *If* operation onto the subgraph data tensors.
The `port_map` entries can be `input` and `output`. Each entry describes a corresponding mapping rule.
*If* has two *port_maps*: `then_port_map` for `then_body` and `else_port_map` for `else_body`.
* **Port map attributes**:
* *external_port_id*
* **Description**: *external_port_id* is a port ID of *If* operation.
* **Range of values**: IDs of the *If* inputs and outputs
* **Type**: `unsigned int`
* **Default value**: None
* **Required**: *yes*
* *internal_layer_id*
* **Description**: *internal_layer_id* is a `Parameter` or `Result` operation ID inside
the subgraph to map to.
* **Range of values**: IDs of the `Parameter` or `Result` operations in the subgraph
* **Type**: `unsigned int`
* **Default value**: None
* **Required**: *yes*
**If Inputs**
* **cond**: A scalar or 1D tensor with 1 element of `boolean` type specifying which subgraph to execute.
`True` value means to execute the `then_body`, `False` - `else_body`. *Required*.
* **Multiple other inputs**: Tensors of different types and shapes. *Optional*.
**If Outputs**
* **Multiple outputs**: Results of execution of one of the subgraph. Tensors of any type and shape.
**Body Inputs**
* **Multiple inputs**: Tensors of different types and shapes. *Optional*.
**Body Outputs**
* **Multiple outputs**: Results of execution of the subgraph. Tensors of any type and shape.
**Examples**
*Example 1: a typical If structure*
```xml
242424242424242424
```