<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getitem(lst, indices):
 """Definition for multidimensional slicing and indexing on arbitrarily shaped nested lists. """

    if not indices:
        return lst

    i, indices = indices[0], indices[1:]
    item = list.__getitem__(lst, i)

    if isinstance(i, int):
        return getitem(item, indices)

    # Empty slice: check if all subsequent indices are in range for the
    # full slice, raise IndexError otherwise. This is NumPy's behavior.
    if not item:
        if lst:
           _ = getitem(lst, (slice(None),) + indices)
        elif any(isinstance(k, int) for k in indices):
           raise IndexError
        return []

    return [getitem(x, indices) for x in item]