# tff.sequence_map

<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) |

Maps a TFF sequence `value` pointwise using a given function `fn`.

    tff.sequence_map(
        fn, arg
    )

This function supports two modes of usage:

- When applied to a non-federated sequence, it maps individual elements of
  the sequence pointwise. If the supplied `fn` is of type `T->U` and
  the sequence `arg` is of type `T*` (a sequence of `T`-typed elements),
  the result is a sequence of type `U*` (a sequence of `U`-typed elements),
  with each element of the input sequence individually mapped by `fn`.
  In this mode of usage, `sequence_map` behaves like a computatation with type
  signature `<T->U,T*> -> U*`.

- When applied to a federated sequence, `sequence_map` behaves as if it were
  individually applied to each member constituent. In this mode of usage, one
  can think of `sequence_map` as a specialized variant of `federated_map` that
  is designed to work with sequences and allows one to
  specify a `fn` that operates at the level of individual elements.
  Indeed, under the hood, when `sequence_map` is invoked on a federated type,
  it injects `federated_map`, thus
  emitting expressions like
  `federated_map(a -> sequence_map(fn, x), arg)`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `fn` | A mapping function to apply pointwise to elements of `arg`. |
| `arg` | A value of a TFF type that is either a sequence, or a federated sequence. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A sequence with the result of applying `fn` pointwise to each element of `arg`, or if `arg` was federated, a federated sequence with the result of invoking `sequence_map` on member sequences locally and independently at each location. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the arguments are not of the appropriate types. |

<br />