original_docstring: 
      Helper function to write out IMEIs that are seen on multiple operators that have been classified.
  
      Arguments:
          conn: DIRBS PostgreSQL connection object
          config: DIRBS config object
          month: month of the report
          year: year of the report
          country_name: name of the country
          output_dir: output directory path
          cond_names: list of condition names
      Returns:
          Reports metadata
      
docstring: Helper function to write out IMEIs that are seen on multiple operators that have been classified.
docstring_tokens: Helper function to write out IMEIs that are seen on multiple operators that have been classified .
code: def write_condition_imei_overlaps(conn: callable, config: callable, month: int, year: int,
                                    country_name: str, output_dir: str, cond_names: list) -> callable:
      """
      Helper function to write out IMEIs that are seen on multiple operators that have been classified.
  
      Arguments:
          conn: DIRBS PostgreSQL connection object
          config: DIRBS config object
          month: month of the report
          year: year of the report
          country_name: name of the country
          output_dir: output directory path
          cond_names: list of condition names
      Returns:
          Reports metadata
      """
      with contextlib.ExitStack() as stack:
          # Push files into exit stack so that they will all be closed.
          filename_cond_map = {'{0}_{1:d}_{2:d}_condition_imei_overlap_{3}.csv'.format(country_name, month, year, c): c
                               for c in cond_names}
          condname_file_map = {c: stack.enter_context(open(os.path.join(output_dir, fn), 'w', encoding='utf8'))
                               for fn, c in filename_cond_map.items()}
          # Create a map from condition name to csv writer
          condname_csvwriter_map = {c: csv.writer(condname_file_map[c]) for c in cond_names}
          # Write the header to each csvwriter
          for _, writer in condname_csvwriter_map.items():
              writer.writerow(['IMEI', 'Operators'])
          # Runa query to find all the classified IMEIs seen on multiple operators
          with conn.cursor(name='imeis_overlap') as cursor:
              cursor.execute("""SELECT imei_norm, cond_name, string_agg(DISTINCT operator_id, '|') AS operators
                                  FROM classification_state
                                  JOIN monthly_network_triplets_per_mno_no_null_imeis
                                 USING (imei_norm)
                                 WHERE triplet_month = %s
                                   AND triplet_year = %s
                                   AND end_date IS NULL
                              GROUP BY imei_norm, cond_name
                                       HAVING COUNT(DISTINCT operator_id) > 1""",
                             [month, year])
              for res in cursor:
                  condname_csvwriter_map[res.cond_name].writerow([res.imei_norm, res.operators])
  
      return _gen_metadata_for_reports(list(filename_cond_map.keys()), output_dir)
code_tokens: def write_condition_imei_overlaps ( conn : callable , config : callable , month : int , year : int , country_name : str , output_dir : str , cond_names : list ) -> callable : with contextlib . ExitStack ( ) as stack : filename_cond_map = { '{0}_{1:d}_{2:d}_condition_imei_overlap_{3}.csv' . format ( country_name , month , year , c ) : c for c in cond_names } condname_file_map = { c : stack . enter_context ( open ( os . path . join ( output_dir , fn ) , 'w' , encoding = 'utf8' ) ) for fn , c in filename_cond_map . items ( ) } condname_csvwriter_map = { c : csv . writer ( condname_file_map [ c ] ) for c in cond_names } for _ , writer in condname_csvwriter_map . items ( ) : writer . writerow ( [ 'IMEI' , 'Operators' ] ) with conn . cursor ( name = 'imeis_overlap' ) as cursor : cursor . execute ( """SELECT imei_norm, cond_name, string_agg(DISTINCT operator_id, '|') AS operators
                                  FROM classification_state
                                  JOIN monthly_network_triplets_per_mno_no_null_imeis
                                 USING (imei_norm)
                                 WHERE triplet_month = %s
                                   AND triplet_year = %s
                                   AND end_date IS NULL
                              GROUP BY imei_norm, cond_name
                                       HAVING COUNT(DISTINCT operator_id) > 1""" , [ month , year ] ) for res in cursor : condname_csvwriter_map [ res . cond_name ] . writerow ( [ res . imei_norm , res . operators ] ) return _gen_metadata_for_reports ( list ( filename_cond_map . keys ( ) ) , output_dir )
short_docstring: Helper function to write out IMEIs that are seen on multiple operators that have been classified.
short_docstring_tokens: Helper function to write out IMEIs that are seen on multiple operators that have been classified .
comment: """
      Helper function to write out IMEIs that are seen on multiple operators that have been classified.
  
      Arguments:
          conn: DIRBS PostgreSQL connection object
          config: DIRBS config object
          month: month of the report
          year: year of the report
          country_name: name of the country
          output_dir: output directory path
          cond_names: list of condition names
      Returns:
          Reports metadata
      """$SEP$# Push files into exit stack so that they will all be closed.$SEP$# Create a map from condition name to csv writer$SEP$# Write the header to each csvwriter$SEP$# Runa query to find all the classified IMEIs seen on multiple operators