torch_elementwise_function

probly.representation.sample.torch_functions.torch_elementwise_function(func: Callable, args: tuple[Any, ...], kwargs: dict[str, Any]) → Any[source]

Apply elementwise operations while preserving aligned sample axes and weights.

Parameters:
  • func – The torch function to apply.

  • args – Positional arguments to the function.

  • kwargs – Keyword arguments to the function.

Returns:

A sample when sample axes align, a native result otherwise, or the out buffer.

Raises:

ValueError – If aligned operands have conflicting sample weights.