```python:inference/core/workflows/execution_engine/v1/executor/execution_data_manager/step_input_assembler.py
from inference.core.workflows.execution_engine.v1.executor.execution_data_manager.dynamic_batches_manager import DynamicBatchIndex
from typing import Dict, List, Set

def intersect_masks_per_dimension(
    batch_masks: List[Set[DynamicBatchIndex]],
    dimensions: Set[int],
) -> Dict[int, Set[DynamicBatchIndex]]:
    """Intersect masks at each dimensionality level.

    For each dimension d, returns the set of indices (with length d) that appear
    in every mask that has at least one index at that dimension. Masks with no
    indices at d are ignored for that dimension. Used for intra-dimensional
    intersection.
    """
    sorted_dims = sorted(dimensions)
    result: Dict[int, Set[DynamicBatchIndex]] = {}
    for dim in sorted_dims:
        intersection = None
        for mask in batch_masks:
            indices_at_dim = {idx for idx in mask if len(idx) == dim}
            if not indices_at_dim:
                continue
            if intersection is None:
                intersection = indices_at_dim
            else:
                intersection &= indices_at_dim
        result[dim] = intersection if intersection is not None else set()
    return result
```