{% import 'main.j2' as main with context %}
# This file was autogenerated by PeakRDL-pyuvm
from typing import TypeVar, Callable

import numpy as np
from numpy.typing import NDArray

from pyuvm import (
    uvm_coverage_model_e,
    uvm_endianness_e,
    uvm_mem,
    uvm_reg,
    uvm_reg_block,
    uvm_reg_field,
)

T = TypeVar('T')


def create_object_array(factory: Callable[[], T], name: str, dimensions: list[int]) -> NDArray[T]:
    """
    Creates a multidimensional NumPy array with the given `dimensions`, where each element
    is created by calling `factory`.

    Parameters:
        dimensions (list[int]): The size of each dimension in the resulting array.
        factory (Callable[[], T]): A no-argument callable (like a class or function)
                                   that returns an instance of T.

    Returns:
        NDArray[T]: A NumPy array populated with instances created by factory().
    """
    arr = np.empty(dimensions, dtype=object)
    for idx in np.ndindex(*dimensions):
        indicies = ''.join(f'[{i}]' for i in idx)
        arr[idx] = factory(f"{name}{indicies}")
    return arr

{{ main.top()}}
