<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def est_via_matching(self, weights='inv', matches=1, bias_adj=False):
 		""" 		Estimates average treatment effects using nearest- 		neighborhood matching. 		Matching is done with replacement. Method supports multiple 		matching. Correcting bias that arise due to imperfect matches 		is also supported. For details on methodology, see [1]_. 		Parameters 		weights: str or positive definite square matrix 			Specifies weighting matrix used in computing 			distance measures. Defaults to string 'inv', 			which does inverse variance weighting. String 			'maha' gives the weighting matrix used in the 			Mahalanobis metric. 		matches: int 			Number of matches to use for each subject. 		bias_adj: bool 			Specifies whether bias adjustments should be 			attempted. 		References 		.. [1] Imbens, G. & Rubin, D. (2015). Causal Inference in 			Statistics, Social, and Biomedical Sciences: An 			Introduction. 		"""


		X, K = self.raw_data['X'], self.raw_data['K']
		X_c, X_t = self.raw_data['X_c'], self.raw_data['X_t']

		if weights == 'inv':
			W = 1/X.var(0)
		elif weights == 'maha':
			V_c = np.cov(X_c, rowvar=False, ddof=0)
			V_t = np.cov(X_t, rowvar=False, ddof=0)
			if K == 1:
				W = 1/np.array([[(V_c+V_t)/2]])  # matrix form
			else:
				W = np.linalg.inv((V_c+V_t)/2)
		else:
			W = weights

		self.estimates['matching'] = Matching(self.raw_data, W,
		                                      matches, bias_adj)