<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _create_subplots(self, fig, layout):
 """ Create suplots and return axs """

        num_panels = len(layout)
        axsarr = np.empty((self.nrow, self.ncol), dtype=object)

        # Create axes
        i = 1
        for row in range(self.nrow):
            for col in range(self.ncol):
                axsarr[row, col] = fig.add_subplot(self.nrow, self.ncol, i)
                i += 1

        # Rearrange axes
        # They are ordered to match the positions in the layout table
        if self.dir == 'h':
            order = 'C'
            if not self.as_table:
                axsarr = axsarr[::-1]
        elif self.dir == 'v':
            order = 'F'
            if not self.as_table:
                axsarr = np.array([row[::-1] for row in axsarr])

        axs = axsarr.ravel(order)

        # Delete unused axes
        for ax in axs[num_panels:]:
            fig.delaxes(ax)
        axs = axs[:num_panels]
        return axs