<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

An implementation of [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) representing structural types in TFF.

Inherits From: [`Struct`](https://www.tensorflow.org/federated/api_docs/python/tff/structure/Struct), [`Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type)

#### View aliases


**Main aliases**

[`tff.StructType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/StructType)

<br />

    tff.types.StructType(
        elements: Iterable[object], *, convert: bool = True
    )

Elements initialized by name can be accessed as `foo.name`, and otherwise by
index, `foo[index]`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `elements` | An iterable of element specifications. Each element specification is either a type spec (an instance of [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) or something convertible to it via [`tff.types.to_type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/to_type)) for the element, or a (name, spec) for elements that have defined names. Alternatively, one can supply here an instance of `collections.OrderedDict` mapping element names to their types (or things that are convertible to types). |
| `convert` | A flag to determine if the elements should be converted using [`tff.types.to_type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/to_type) or not. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `python_container` | <br /> <br /> |

<br />

## Methods

### `check_assignable_from`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    check_assignable_from(
        source_type: 'Type'
    ) -> None

Raises if values of `source_type` cannot be cast to this type.

### `check_equivalent_to`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    check_equivalent_to(
        other: 'Type'
    ) -> None

Raises if values of 'other' cannot be cast to and from this type.

### `check_identical_to`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    check_identical_to(
        other: 'Type'
    ) -> None

Raises if `other` and `Type` are not exactly identical.

### `children`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    children() -> Iterator[Type]

Returns a generator yielding immediate child types.

### `compact_representation`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    compact_representation() -> str

Returns the compact string representation of this type.

### `formatted_representation`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    formatted_representation() -> str

Returns the formatted string representation of this type.

### `is_assignable_from`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    is_assignable_from(
        source_type: https://www.tensorflow.org/federated/api_docs/python/tff/types/Type
    ) -> bool

Returns whether values of `source_type` can be cast to this type.

### `is_equivalent_to`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    is_equivalent_to(
        other: 'Type'
    ) -> bool

Returns whether values of `other` can be cast to and from this type.

### `is_identical_to`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    is_identical_to(
        other: 'Type'
    ) -> bool

Returns whether or not `self` and `other` are exactly identical.

### `named`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    named(
        **kwargs
    ) -> 'Struct'

Constructs a new `Struct` with all named elements.

### `unnamed`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    unnamed(
        *args
    ) -> 'Struct'

Constructs a new `Struct` with all unnamed elements.

### `__eq__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __eq__(
        other
    )

Return self==value.

### `__getitem__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __getitem__(
        key: Union[int, str, slice]
    ) -> _T

### `__iter__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __iter__() -> Iterator[_T]

### `__len__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __len__() -> int

### `__ne__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __ne__(
        other: object
    ) -> bool

Return self!=value.