o
    7tij                  
   @   s   d dl Z d dlmZ d dlZzedZdgZdggZej	eedgdZ
W n ey3 Z zedZ[ww deeee f d	eeeee  f d
efddZded
efddZdeee  dee d
eee  fddZdd ZdS )    N)Union	code_evalzassert add(2, 3)==5zdef add(a,b): return a*b   
referencespredictionskr   r   returnc                 C   sF   t | tr| g} t |d trdd |D }tj| |dgdd d S )Nr   c                 S   s   g | ]}|gqS  r
   ).0pr
   r
   L/home/ubuntu/.local/lib/python3.10/site-packages/lm_eval/tasks/mbpp/utils.py
<listcomp>   s    zpass_at_1.<locals>.<listcomp>r   r   zpass@1)
isinstancestr	pass_at_kcompute)r   r   r
   r
   r   	pass_at_1   s   
r   textc                 C   sJ   d}t |d|  t j}|st dd| }t ||t j}|s!dS |d S )Nz```(?:\w+)?\n?(.*?)\n?```z```z	```python r   )refindallDOTALLsub)r   patternmatchestext_without_langr
   r
   r   extract_code_blocks    s   r   respsdocsc                 C   s   dd | D S )Nc                 S   s   g | ]	}d d |D qS )c                 S   s   g | ]}t |qS r
   )r   )r   rr
   r
   r   r   0   s    z0build_predictions.<locals>.<listcomp>.<listcomp>r
   )r   respr
   r
   r   r   0   s    z%build_predictions.<locals>.<listcomp>r
   )r   r   r
   r
   r   build_predictions/   s   r"   c                   C   s:   dddg dddddd	g d
dddddg dddgS )N   zMWrite a function to find the similar elements from the given two tuple lists.zldef similar_elements(test_tup1, test_tup2):
  res = tuple(set(test_tup1) & set(test_tup2))
  return (res) )z=assert similar_elements((3, 4, 5, 6),(5, 7, 4, 10)) == (4, 5)z<assert similar_elements((1, 2, 3, 4),(5, 4, 3, 7)) == (3, 4)zFassert similar_elements((11, 12, 14, 13),(17, 15, 14, 13)) == (13, 14)T)task_idr   code	test_list
is_fewshot   z6Write a python function to identify non-prime numbers.zimport math
def is_not_prime(n):
    result = False
    for i in range(2,int(math.sqrt(n)) + 1):
        if n % i == 0:
            result = True
    return result)zassert is_not_prime(2) == Falsezassert is_not_prime(10) == Truezassert is_not_prime(35) == True   zfWrite a function to find the largest integers from a given list of numbers using heap queue algorithm.zqimport heapq as hq
def heap_queue_largest(nums,n):
  largest_nums = hq.nlargest(n, nums)
  return largest_nums)zQassert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65] zMassert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],2)==[85, 75] zXassert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[85, 75, 65, 58, 35]r
   r
   r
   r
   r   list_fewshot_samples3   s&   r*   )r   typingr   evaluatehf_evaluateloadr   
test_cases
candidatesr   results	Exceptioner   listfloatr   r   dictr"   r*   r
   r
   r
   r   <module>   s,    

*