<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _chi_lr(self,r, phi, nl,nr,beta):
 """ computes the generalized polar basis function in the convention of Massey&Refregier eqn 8 :param nl: left basis :type nl: int :param nr: right basis :type nr: int :param beta: beta --the characteristic scale typically choosen to be close to the size of the object. :type beta: float. :param coord: coordinates [r,phi] :type coord: array(n,2) :returns: values at positions of coordinates. :raises: AttributeError, KeyError """

        m=int((nr-nl).real)
        n=int((nr+nl).real)
        p=int((n-abs(m))/2)
        p2=int((n+abs(m))/2)
        q=int(abs(m))
        if p % 2==0: #if p is even
            prefac=1
        else:
            prefac=-1
        prefactor=prefac/beta**(abs(m)+1)*np.sqrt(math.factorial(p)/(np.pi*math.factorial(p2)))
        poly=self.poly[p][q]
        return prefactor*r**q*poly((r/beta)**2)*np.exp(-(r/beta)**2/2)*np.exp(-1j*m*phi)