def _identical_trailing_dimensions(larger_array, smaller_array):
    """Check if trailing dimensions of two arrays are identical."""
    if larger_array.ndim < smaller_array.ndim:
        raise ValueError(
            f"Expected array with higher number of dimensions as first "
            f"argument, got {larger_array.ndim:d}D array as first argument, "
            f"{smaller_array.ndim:d}D array as second")
    return larger_array.shape[-smaller_array.ndim:] == smaller_array.shape