hyped.core package¶
Subpackages¶
Submodules¶
- hyped.core.abc module
- hyped.core.builder module
- hyped.core.executor module
- hyped.core.flow module
- hyped.core.graph module
DataFlowGraphDataFlowGraph.GraphAttributeDataFlowGraph.NodeAttributeDataFlowGraph.NodeTypeDataFlowGraph.PartitionDataFlowGraph.add_node()DataFlowGraph.add_source_node()DataFlowGraph.dependency_graph()DataFlowGraph.depthDataFlowGraph.drop_partition()DataFlowGraph.format()DataFlowGraph.from_dict()DataFlowGraph.get_output_dtype()DataFlowGraph.get_partition()DataFlowGraph.recompute_depths()DataFlowGraph.src_dtypeDataFlowGraph.src_node_idDataFlowGraph.subgraph_in_edges()DataFlowGraph.subgraph_out_edges()DataFlowGraph.to_dict()DataFlowGraph.to_string()DataFlowGraph.width
logical_imply()
- hyped.core.module module
- hyped.core.optim module
- hyped.core.typing module
- hyped.core.utils module
Module contents¶
The core package for defining and executing data flows as directed acyclic graphs (DAGs).
This package provides the necessary classes and methods to construct, manage, and execute complex data processing workflows. It uses a graph-based approach where each node represents a data processor, and edges represent the flow of data between processors.
- Modules:
executor: Manages the execution of the data flow graph.flow: Provides the high-level interface for defining data processing workflows.graph: Defines the structure of the data flow graph and its components.optim: Defines an Optimizer to optimize the graph of the data flow.typing: Defines core type aliases including those used to define node interfaces.nodes: Defines the base classes for nodes of the DAG.features: The feature system.ops: Implementation of core operations.testing: Defines base classes to implement node tests.
While these modules are crucial for processor development, they are not intended for direct use by end users interacting with the high-level data flow interface.
- class hyped.core.BaseDataAggregator(*args: Any, **kwargs: Any)[source]¶
-
Base class for data aggregators.
This class serves as the base for all data aggregators, defining the necessary interfaces and methods for implementing custom aggregators. Subclasses must implement the extract and update methods, which define the logic for retrieving and updating aggregated values in the data flow graph.
- Extracted = ~Extract¶
- State = ~State¶
- Value = ~Value¶
- abstractmethod async extract(ctx: RunContext, *args: Feature, **kwargs: Feature) Extracted[source]¶
Extract necessary values from the inputs for aggregation.
- Parameters:
ctx (RunContext) – The run context object.
*args (Feature) – Positional input arguments.
**kwargs (Feature) – Keyword input arguments.
- Returns:
The extracted context values required for aggregation.
- Return type:
Extract
- abstractmethod seed(ctx: RunContext) tuple[Value, State][source]¶
Compute the seed aggregation value and state.
Note that the
seed()function is not part of the data flow execution but of the initialization process. Therefore, it is called beforeinitialize()of the node and thectx.sessionwill beNone.- Parameters:
ctx (RunContext) – The run context object with
session=None.- Returns:
The initial value and state for the aggregator.
- Return type:
- property signature: Signature¶
Retrieve the signature for the aggregator node.
This method constructs a signature for the aggregator node by combining the parameters of the
extract()method with the return annotation of theupdate()method. Thectxparameter is excluded from the parameter list, ensuring that the signature reflects only the feature inputs relevant to the aggregation process.The return annotation of the signature is derived from the
update()method, representing the aggregated feature type produced by the aggregator node.
- class hyped.core.BaseDataAggregatorConfig[source]¶
Bases:
BaseNodeConfigBase configuration class for data aggregators.
This class serves as the base configuration class for data aggregators. It inherits from
BaseConfig, providing basic configuration functionality for data aggregation tasks.- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hyped.core.BaseDataAugmentor(*args: Any, **kwargs: Any)[source]¶
-
Base class for data augmentors in a data flow graph.
This class represents a data augmentor node in a data flow graph. Data augmentors modify or generate new samples from existing ones, which can include filtering or creating new data points. Subclasses of
BaseDataAugmentormust implement either theprocessor thebatch_processmethod to define how the augmentation is applied to the input data.- infer_output_partition(ctx: RunContext, partition: str) str[source]¶
Determine the output partition of the augmentater.
By default, data augmentors point to their own partition. This method reuses the node ID of the augmentor as the output partition ID.
Note that this function is not part of the data flow execution but of the initialization process. Therefore, it is called before
initialize()of the node and thectx.sessionwill beNone.- Parameters:
ctx (RunContext) – Execution context for the node.
partition (PartitionId) – The ID of the input partition, i.e. the partition that the node is assigned to.
- Returns:
The output partition ID, corresponding to the node ID of the augmentor.
- Return type:
- abstractmethod process(ctx: RunContext, *args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) AsyncIterable[Feature | Any | list[Any] | Scalar | Array][source]¶
- abstractmethod process(ctx: RunContext, *args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) Iterable[Feature | Any | list[Any] | Scalar | Array]
- abstractmethod process(ctx: RunContext, *args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) tuple[Feature | Any | list[Any] | Scalar | Array, list[int]]
- abstractmethod process(ctx: RunContext, *args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) tuple[Feature | Any | list[Any] | Scalar | Array, list[int]]
Defines the augmentation logic to be applied.
This method should be overridden by subclasses to define the augmentation logic. It may either be synchronous or asynchronous, depending on the subclass.
- Parameters:
ctx (RunContext) – Context information for the data augmentor’s execution.
*args (Feature) – Positional input arguments.
**kwargs (Feature) – Keyword arguments.
- Returns:
Iterable[Feature]: If the process function is synchronous, it returns an iterable of augmented output samples, potentially producing multiple outputs per input.
AsyncIterable[Feature]: If the process function is asynchronous, it returns an async iterable of augmented output samples, following the same logic as the synchronous mode.
tuple[Feature, TraceIndexList]: If the process function operates in batched mode, it returns:
Feature: A batch of augmented output samples.
TraceIndexList: A list of trace indices mapping each output sample to the corresponding source sample in the input batch. Specifically, the
i-th output sample originates from thetrace_index[i]-th input example.
- Return type:
Union[Iterable[Feature], AsyncIterable[Feature], tuple[Feature, TraceIndexList]]
- async run(ctx: RunContext, arrays: dict[str, Array]) tuple[Array, list[int]][source]¶
Execute the main processing logic for the data augmentor.
This method serves as the primary entry point for processing data within a data flow graph, returning both the processed outputs and their associated trace indices. It orchestrates the execution of the
processmethod according to the configuredProcessMode, handling input preparation, processing, and output finalization. In detail, the workflow is:Determine the processing mode (
ProcessMode) based on theprocessmethod’s configuration.Prepare the input data using the
ProcessMode.preparemethod.Apply the
processmethod to the prepared inputs. If the method is asynchronous, the outputs are awaited usingasyncio.gather.Depending on whether the processing is batched: - If batched:
Separate the outputs and their associated trace indices from the
processmethod’s results.Concatenate the trace indices and finalize the outputs as a
PyArrowarray.
If non-batched: a. Collect all outputs and trace indices from the
processmethod,consuming asynchronous or synchronous iterators as appropriate.
Chain the outputs and finalize them as a
PyArrowarray.Build a trace index list that maps each output sample back to its corresponding input.
- Parameters:
ctx (RunContext) – The execution context containing.
arrays (dict[str, pa.Array]) – A dictionary mapping input names to
PyArrowarrays, representing the input data to be processed.
- Returns:
A tuple containing the processed output as a
PyArrowarray and a list of trace indices mapping the output samples to their respective input sources.- Return type:
tuple[pa.Array, TraceIndexList]
- property signature: Signature¶
Get the signature of the
process()method.Returns the signature of the
process()method with thectxparameter removed, keeping only the feature inputs modeled in the data flow graph.
- class hyped.core.BaseDataAugmentorConfig[source]¶
Bases:
BaseNodeConfigBase configuration class for data augmentors.
This class serves as the base configuration for data augmentors, inheriting from
BaseNodeConfigto provide configuration functionality specifically for data augmentation tasks.- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hyped.core.BaseDataProcessor(*args: Any, **kwargs: Any)[source]¶
-
Base class for data processors in a data flow graph.
This class serves as the base for all data processors, representing nodes in a data flow graph. Subclasses of
BaseDataProcessorimplement specific process functions that map input features to output features. Custom data processors must either override thebatch_process()method or theprocess()method to define their processing logic.- abstractmethod process(ctx: RunContext, *args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) Feature | Any | list[Any] | Scalar | Array[source]¶
Process function.
This method should be implemented by subclasses to define the processing logic. It may either be synchronous or asynchronous, depending on the subclass.
- Parameters:
ctx (RunContext) – The context for the current process call.
*args (Feature) – Positional feature arguments.
**kwargs (Feature) – Keyword feature arguments.
- Returns:
The resulting processed feature.
- Return type:
- async run(ctx: RunContext, arrays: dict[str, Array]) Array[source]¶
Execute the main processing logic for the data processor.
This method serves as the primary entry point for processing data within a data flow graph. It orchestrates the execution of the
processmethod according to the configuredProcessMode, handling input preparation, processing, and output finalization. In detail the workflow is:Determine the processing mode (
ProcessMode) based on theprocessmethod’s configuration.Prepare the input data using the
ProcessMode.preparemethod.Apply the
processmethod to the prepared inputs. If the method is asynchronous, the outputs are awaited usingasyncio.gather.Finalize the outputs using the
ProcessMode.finalizemethod, which ensures that the results are correctly formatted as anPyArrowarray.
- Parameters:
ctx (RunContext) – The execution context containing.
arrays (dict[str, pa.Array]) – A dictionary mapping input names to
PyArrowarrays, representing the input data to be processed.
- Returns:
The processed output as a
PyArrowarray.- Return type:
pa.Array
- property signature: Signature¶
Get the signature of the
process()method.Returns the signature of the
process()method with thectxparameter removed, keeping only the feature inputs modeled in the data flow graph.- Returns:
The signature of the
process()method excluding thectxparameter.- Return type:
- class hyped.core.BaseDataProcessorConfig[source]¶
Bases:
BaseNodeConfigBase configuration class for data processors.
This class serves as the base configuration class for data processors. It inherits from
BaseNodeConfig, a Pydantic model, providing basic configuration functionality for data processing tasks.- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class hyped.core.DataFlow(features: None | Features = None)[source]¶
Bases:
AbstractDataFlow,Generic[T]Data Flow.
The
DataFlowclass allows users to create and manage directed acyclic graphs (DAGs) of data processors, facilitating complex data transformations and processing pipelines. Users can easily define source features, build sub-flows for specific outputs, and apply these workflows to batches of data or entire HuggingFace datasets.This class integrates various components such as the data flow graph and the executor to provide a seamless experience for processing data. It handles the internal state management, execution scheduling, and data flow dependencies to ensure efficient and accurate data processing.
- U = ~U¶
- apply(ds: Dataset, collect: Feature | dict[str, Any], *, debug: bool = False, batch_size: int = 1000, drop_last_batch: bool = False, keep_in_memory: bool = False, load_from_cache_file: bool = True, writer_batch_size: int = 1000, num_proc: None | int = None, desc: None | str = None) Dataset[source]¶
- apply(ds: Dataset, collect: Feature | dict[str, Any], aggregate: Feature | dict[str, Any], *, debug: bool = False, batch_size: int = 1000, drop_last_batch: bool = False, keep_in_memory: bool = False, load_from_cache_file: bool = True, writer_batch_size: int = 1000, num_proc: None | int = None, desc: None | str = None) tuple[Dataset, dict[str, Any]]
- apply(ds: ItDataset, collect: Feature | dict[str, Any], *, debug: bool = False, batch_size: int = 1000, drop_last_batch: bool = False) ItDataset
- apply(ds: ItDataset, collect: Feature | dict[str, Any], aggregate: Feature | dict[str, Any], *, debug: bool = False, batch_size: int = 1000, drop_last_batch: bool = False) tuple[ItDataset, dict[str, Any]]
Apply the data flow graph to a dataset.
This method processes a given dataset or iterable dataset using the data flow graph, executing transformations based on the
collectand optionalaggregatefeatures. The behavior of the processing depends on whether the dataset is an in-memory or streamed dataset (i.e.datasets.Datasetordatasets.IterableDataset)).- Parameters:
ds (Dataset | IterableDataset) – The dataset to which the data flow graph will be applied.
collect (Feature | dict[str, Any]) – The collect feature, which defines the primary transformations applied to the dataset.
aggregate (None | Feature | dict[str, Any]) – An optional aggregate feature, which applies additional aggregate-level transformations. If not provided, aggregation is skipped.
debug (bool) – If True, executes debug nodes allowing for inspection of intermediate data. Defaults to
False.batch_size (int) – The number of samples to process in a batch. Defaults to 1000.
drop_last_batch (bool) – Whether to drop the last batch if it is smaller than the specified batch size. Defaults to
False.keep_in_memory (bool) – If
True, the resulting dataset is kept in memory. Defaults toFalse. Only applies fordatasets.Dataset.load_from_cache_file (bool) – Whether to load the resulting dataset from cache files when possible. Defaults to
True. Only applies fordatasets.Dataset.writer_batch_size (int) – Batch size for writing results to cache files. Defaults to 1000. Only applies for
datasets.Dataset.num_proc (None | int) – The number of processes to use for parallel processing. Defaults to
None, which disables multiprocessing. Only applies fordatasets.Dataset.desc (Optional[str], optional, only for Dataset) – A description for the progress bar displayed during processing. Defaults to
None. Only applies fordatasets.Dataset.
- Returns:
The transformed dataset matching the input dataset type and a dictionary containing the aggregation results when aggregation is applied, i.e. the
aggregateinput is specified.- Return type:
Dataset | ItDataset | tuple[Dataset, dict[str, Any]] | tuple[ItDataset, dict[str, Any]]
- build(collect: Feature | dict[str, Any], aggregate: None | Feature | dict[str, Any] = None, *, aggregation_manager: DataAggregationManager | None = None, debug: bool = True) ExecutableDataFlow[source]¶
Build an executable data flow for computing and collecting features.
This method constructs a read-only, executable representation of the data flow for a specified
collectfeature. Optionally, anaggregatefeature can also be included for dataset-wide computations. The resulting data flow is optimized for execution.- Parameters:
collect (Feature | dict[str, Any]) – The feature to be computed and collected.
aggregate (None | Feature) – An optional feature for computing aggregated values across the dataset.
*
aggregation_manager (DataAggregationManager | None) – The data aggregation manager instance.
debug (bool) – If True, includes debug nodes in the built data flow, allowing for inspection of intermediate data. Defaults to
True.
- Returns:
An executable data flow that encapsulates the graph, collect feature, and optional aggregate feature.
- Return type:
- Raises:
RuntimeError – If the
collectfeature does not belong to the current data flow graph.RuntimeError – If the
aggregatefeature does not belong to the current data flow graph.
- collect(collect: dict[dict[str, dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | list[dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | tuple[dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | Any]) _MappingFeature[source]¶
- collect(collect: list[dict[str, dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | list[dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | tuple[dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | Any] | tuple[dict[str, dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | list[dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | tuple[dict[str, NestedType] | list[NestedType] | tuple[NestedType] | T] | Any]) SequenceFeature
- collect(collect: Any) Feature
Add a collect node to the data flow.
The
collect()method processes a nested structure (e.g., dicts, lists, tuples) of constants and features and adds a correspondingcollectnode to the data flow graph. Constants are converted to constant nodes, while features are directly incorporated.- Parameters:
collect (NestedType[Any]) – A nested structure of constants, Feature objects, and Reference instances. The structure may include dictionaries, lists, and tuples, where constants are automatically added as constant nodes.
- Returns:
- A feature or nested structure of features representing
the collected data.
- Return type:
- Raises:
NotImplementedError – If an empty sequence (list or tuple) is encountered.
TypeError – If an unsupported type is encountered in the nested structure.
- const(value: int) Int64Feature[source]¶
- const(value: float) Float64Feature
- const(value: bool) BoolFeature
- const(value: str) StringFeature
- const(value: dict[str, Any]) _MappingFeature
- const(value: list[Any] | tuple[Any]) SequenceFeature
- const(value: Any, feature_type: type[U]) U
Add a constant value as a node to the data flow.
This method allows the user to add a constant value as a node in the data flow graph. The constant can either be associated with a specific feature type or have its data type inferred from the provided value.
- Parameters:
- Returns:
The feature representation of the constant node added to the graph.
- Return type:
- Raises:
TypeError – If the provided
feature_typeis invalid or if the value cannot be validated against thefeature_type.
- property depth: int¶
Computes the total depth of the data flow graph.
The depth is defined as the maximum level of any node in the graph, where the root node has a depth of 0. This property calculates the depth by finding the maximum depth attribute among all nodes in the graph.
- Returns:
The total depth of the graph.
- Return type:
- classmethod deserialize(data: str, debug: bool = True) ExecutableDataFlow[source]¶
Deserializes a JSON string into an
ExecutableDataFlowinstance.This method parses a JSON string into a dictionary, validates its structure, and uses the data to reconstruct the executable data flow, including references to the collection and aggregation nodes.
- Parameters:
- Returns:
The deserialized executable data flow.
- Return type:
- Raises:
ValueError – If the input JSON string does not contain the required keys (“graph”, “collect”, and “aggregate”).
- property source: T¶
Get the source features.
- Returns:
The reference to the source features.
- Return type:
- property width: int¶
Computes the maximum width of the data flow graph.
The width is defined as the maximum number of nodes present at any single depth level in the graph. This property calculates the width by grouping nodes by their depth and finding the largest group.
- Returns:
The maximum width of the graph.
- Return type:
- class hyped.core.DataFlowModule(debug: bool = True)[source]¶
Bases:
ABCBase class for defining reusable data processing modules.
A DataFlowModule encapsulates a data processing workflow. Subclasses must implement the
call()method, which defines the core logic of the module.- abstractmethod call(*args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) Feature | Any | list[Any] | Scalar | Array[source]¶
Defines the core logic of the data processing module.
Subclasses must implement this method to specify how input features are processed to produce output features. The signature of this method determines the input features of the data flow, and the return type determines the output feature.
Within this method, the
flowproperty provides access to aDataFlowinstance, giving access to functionality like ~.flow.DataFlow.collect.
- property flow: DataFlow | ExecutableDataFlow¶
The executable data flow for this module.
This property lazily builds and returns the data flow instance.
Within the
call()method, this returns a mutableDataFlowinstance, giving access to functionality like ~.flow.DataFlow.collect.Outside of
call(), this returns the buildExecutableDataFlow, which represents the fully constructed and optimized data flow, ready for execution.
- Returns:
The data flow.
- Return type:
- plot(node_format: str | Template = "[{{ node_id[:4] }}] {% if node_type == 'SOURCE_NODE' %}Source{% else %}{{ node_object }}{% endif %}", with_edge_labels: bool = True, edge_font_size: int = 6, node_font_size: int = 6, node_size: int = 5000, arrowsize: int = 25, color_map: dict[NodeType, str] = {}, legend: bool = True, legend_fontsize: int = 6, ax: None | Axes = None) Axes[source]¶
Plot a data flow graph.
- Parameters:
flow (DataFlow) – The data flow to plot.
node_format (str | Template) – The jinja template used to generate node labels.
with_edge_labels (bool) – Whether to include labels on the edges. Defaults to True.
edge_font_size (int) – The font size for edge labels. Defaults to 6.
node_font_size (int) – The font size for node labels. Defaults to 6.
node_size (int) – The size of the nodes. Defaults to 5_000.
arrowsize (int) – The size of the arrows on the edges. Defaults to 25.
color_map (dict[None | type, str]) – indicate custom color scheme based on the processor type. None refers to the source node.
legend (bool) – Whether to add a legend of the node types to the axes. Defaults to True.
legend_fontsize (int) – The font size for the legend. Defaults to 6.
ax (Optional[plt.Axes]) – Matplotlib axes object to draw the plot on. Defaults to None.
- Returns:
The Matplotlib axes object with the plot.
- Return type:
plt.Axes
- class hyped.core.NodeProtocol(*args, **kwargs)[source]¶
Bases:
Protocol,Generic[Params,Return]Protocol for node-like objects in a data flow graph.
This protocol defines the interface for nodes within a data flow graph, including methods for calling nodes with or without an explicit data flow. The
NodeProtocolis parameterized byParams, defining the arguments, andReturn, defining the return type.- call(*args: ~Params, **kwargs: ~Params) Return[source]¶
- call(flow: AbstractDataFlow, *args: ~Params, **kwargs: ~Params) Return
- class hyped.core.RunContext(session: None | RunSession, node_id: str, index: int | list[int], rank: int, input_dtype: MappingType, output_dtype: None | DType, target_batch_size: None | int)[source]¶
Bases:
objectContext information for the node execution.
Serves as an identifier for the specific call to the node within the data flow graph. This is particularly useful when a single node class is used multiple times in a data flow, as
RunContextidentifies the specific instance of the node call, i.e., the specific node in the flow graph.- index: int | list[int]¶
The index or list of indices associated with the processor execution.
This attribute is used to track the position or set of positions for processing data within a specific processor call. It could represent a single index or a list of indices, depending on how the data is partitioned or processed.
- input_dtype: MappingType¶
The expected input data type for the processor.
This attribute defines the type of the data that the processor is designed to handle as input. It typically maps the input data’s structure or schema, providing context for how the data should be processed.
- node_id: str¶
The id of the node in the data flow graph.
This attribute serves as a unique identifier for the context, ensuring each processor call can be distinctly recognized within the flow graph.
- output_dtype: None | DType¶
The type of data the processor will produce as output.
This attribute defines the expected structure or type of the output that the processor will generate. It provides information about the transformation or processing that the input data undergoes and the format of the resulting data.
- rank: int¶
The rank or position of the processor in a parallelized execution.
This attribute identifies the specific rank or position of the processor in a parallelized system (e.g., in distributed or multi-threaded processing). The rank determines the processor’s order or responsibility for a portion of the data during execution.
- session: None | RunSession¶
The run session instance.
- class hyped.core.ValidationSession[source]¶
Bases:
objectA lightweight session context manager for managing key-value contextual data.
This class provides a simple way to store, retrieve, and clear context during a specific scope of execution. Contexts are stored as key-value pairs in an internal dictionary, which is cleared automatically when the top-level session ends.
- clear_context(key: None | Hashable = None) None[source]¶
Clear one or all contexts.
- Parameters:
key (None | Hashable) – The key of the context entry to clear. If None, all contexts are cleared. Defaults to None.
- get_context(key: Hashable) Any[source]¶
Retrieve the context value associated with a specific key.
- Parameters:
key (Hashable) – The key for the context entry to retrieve.
- Returns:
The value associated with the key, or None if the key is not found.
- Return type:
Any
- hyped.core.process_mode(batched: bool = False, backend: Literal['python', 'arrow'] = 'python') Callable[[F], F][source]¶
Decorator to specify the processing mode of a data processing function.
This decorator associates a function with a
ProcessMode, specifying how the function handles its inputs and outputs during execution. The mode defines whether the function operates in batched or non-batched mode and which backend is used for processing (e.g., “python” or “arrow”).Use the
@process_mode(...)decorator to annotate methods or functions that perform data processing. The decorator ensures the function is tagged with the appropriate processing mode, which can be validated or used during runtime.