<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_cells(self, left, right, vertical):
 """ Calculate appropriate figure size based on left and right data. """


        if vertical:
            # calculate required number of cells
            vcells = max(sum(self._shape(l)[0] for l in left),
                         self._shape(right)[0])
            hcells = (max(self._shape(l)[1] for l in left) +
                      self._shape(right)[1])
        else:
            vcells = max([self._shape(l)[0] for l in left] +
                         [self._shape(right)[0]])
            hcells = sum([self._shape(l)[1] for l in left] +
                         [self._shape(right)[1]])
        return hcells, vcells