<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def address_offset(self):
 """ Byte address offset of this node relative to it's parent If this node is an array, it's index must be known Raises ------ ValueError If this property is referenced on a node whose array index is not fully defined """

        if self.inst.is_array:
            if self.current_idx is None:
                raise ValueError("Index of array element must be known to derive address")

            # Calculate the "flattened" index of a general multidimensional array
            # For example, a component array declared as:
            #   foo[S0][S1][S2]
            # and referenced as:
            #   foo[I0][I1][I2]
            # Is flattened like this:
            #   idx = I0*S1*S2 + I1*S2 + I2
            idx = 0
            for i in range(len(self.current_idx)):
                sz = 1
                for j in range(i+1, len(self.inst.array_dimensions)):
                    sz *= self.inst.array_dimensions[j]
                idx += sz * self.current_idx[i]

            offset = self.inst.addr_offset + idx * self.inst.array_stride

        else:
            offset = self.inst.addr_offset

        return offset