<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def subplots(figures,shape=None, 				 shared_xaxes=False, shared_yaxes=False, 				 start_cell='top-left', theme=None,base_layout=None, 				 **kwargs):
 	""" 	Generates a subplot view for a set of figures 	This is a wrapper for plotly.tools.make_subplots 	Parameters: 		figures : [Figures] 			List of Plotly Figures 		shape : (rows,cols) 			Tuple indicating the size of rows and columns 			If omitted then the layout is automatically set 		shared_xaxes : bool 			Assign shared x axes. 			If True, subplots in the same grid column have one common 			shared x-axis at the bottom of the grid. 		shared_yaxes : bool 			Assign shared y axes. 			If True, subplots in the same grid row have one common 			shared y-axis on the left-hand side of the grid. 		start_cell : string 				'bottom-left' 				'top-left' 			Choose the starting cell in the subplot grid used to set the 			domains of the subplots. 		theme : string 			Layout Theme 				solar 				pearl 				white 			see cufflinks.getThemes() for all 			available themes 		base_layout : layout (dict) 			Layout to be used as base where the subplots will be 			added 		subplot_titles : list(string) 			List of strings that contains the titles of each 			plot. 		horizontal_spacing : float 				[0,1] 			Space between subplot columns. 		vertical_spacing : float 			Space between subplot rows. 		specs : list of dicts 			Subplot specifications. 				ex1: specs=[[{}, {}], [{'colspan': 2}, None]] 				ex2: specs=[[{'rowspan': 2}, {}], [None, {}]] 			- Indices of the outer list correspond to subplot grid rows 			 starting from the bottom. The number of rows in 'specs' 			 must be equal to 'rows'. 			- Indices of the inner lists correspond to subplot grid columns 			 starting from the left. The number of columns in 'specs' 			 must be equal to 'cols'. 			- Each item in the 'specs' list corresponds to one subplot 			 in a subplot grid. (N.B. The subplot grid has exactly 'rows' 			 times 'cols' cells.) 			- Use None for blank a subplot cell (or to move pass a col/row span). 			- Note that specs[0][0] has the specs of the 'start_cell' subplot. 			- Each item in 'specs' is a dictionary. 				The available keys are: 				* is_3d (boolean, default=False):
 flag for 3d scenes 				* colspan (int, default=1):
 number of subplot columns 					for this subplot to span. 				* rowspan (int, default=1):
 number of subplot rows 					for this subplot to span. 				* l (float, default=0.0):
 padding left of cell 				* r (float, default=0.0):
 padding right of cell 				* t (float, default=0.0):
 padding right of cell 				* b (float, default=0.0):
 padding bottom of cell 			- Use 'horizontal_spacing' and 'vertical_spacing' to adjust 			 the spacing in between the subplots. 		insets : list of dicts 			Inset specifications. 			- Each item in 'insets' is a dictionary. 				The available keys are: 				* cell (tuple, default=(1,1)):
 (row, col) index of the 					subplot cell to overlay inset axes onto. 				* is_3d (boolean, default=False):
 flag for 3d scenes 				* l (float, default=0.0):
 padding left of inset 					 in fraction of cell width 				* w (float or 'to_end', default='to_end') inset width 					 in fraction of cell width ('to_end': to cell right edge) 				* b (float, default=0.0):
 padding bottom of inset 					 in fraction of cell height 				* h (float or 'to_end', default='to_end') inset height 					 in fraction of cell height ('to_end': to cell top edge) 	"""

	if not isinstance(figures,list):
		figures=[figures]

	if shape:
		rows,cols=shape
		if len(figures)>rows*cols:
			raise Exception("Invalid shape for the number of figures given")
	else:
		if len(figures)==1:
			cols=1
			rows=1
		elif shared_xaxes:
			cols=1
			rows=len(figures)
		elif shared_yaxes:
			cols=len(figures)
			rows=1
		else:
			cols=2
			rows=len(figures)//2+len(figures)%2
	sp,grid_ref=get_subplots(rows=rows,cols=cols,
				             shared_xaxes=shared_xaxes, shared_yaxes=shared_yaxes,
				             start_cell=start_cell, theme=theme,base_layout=base_layout,
				             **kwargs)
	list_ref=(col for row in grid_ref for col in row)
	for i in range(len(figures)):
		while True:
			lr=next(list_ref)
			if lr is not None:
				break
		for _ in figures[i]['data']:
			for axe in lr:
				_.update({'{0}axis'.format(axe[0]):axe})
			sp['data'].append(_)
	# Remove extra plots
	for k in list(sp['layout'].keys()):
		try:
			if int(k[-1])>len(figures):
				del sp['layout'][k]
		except:
			pass

	# Check for non-cartesian plots
	data=sp['data']
	layout=sp['layout']
	for d in data:
		if d['type']=='pie':
			d['domain']={}
			d['domain']['x']=layout['xaxis{0}'.format(d['xaxis'][1:])]['domain']
			d['domain']['y']=layout['yaxis{0}'.format(d['yaxis'][1:])]['domain']
	return sp