MultiChannelFunction

class madspace.MultiChannelFunction(self: madspace._madspace_py.MultiChannelFunction, functions: collections.abc.Sequence[madspace._madspace_py.FunctionGenerator], return_batch_sizes: bool = False)

Bases: FunctionGenerator

Applies one of several channel functions to each slice of the batch.

The FunctionGenerator counterpart of MultiChannelMapping. The batch is partitioned by the per-channel counts in the batch_sizes argument. Each slice is passed through its channel function, and the results are concatenated. All channel functions must share the same argument and return layout, which this class then exposes (Sec. 2.1.1 of [1]).

batch is the leading batch dimension.

Arguments

  • the arguments of the channel functions, plus

  • batch_sizes – the number of batch entries routed to each channel.

Returns

  • the returns of the channel functions, plus

  • batch_sizes – echoed back, only when return_batch_sizes is true.

References

Parameters:
  • functions – The per-channel functions.

  • return_batch_sizes – If true, the batch_sizes argument is also returned.