<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def select_transformers(grid, s_max=None):
 """Selects LV transformer according to peak load of LV grid district. The transformers are chosen according to max. of load case and feedin-case considering load factors and power factor. The MV-LV transformer with the next higher available nominal apparent power is chosen. Therefore, a max. allowed transformer loading of 100% is implicitly assumed. If the peak load exceeds the max. power of a single available transformer, multiple transformer are build. By default `peak_load` and `peak_generation` are taken from `grid` instance. The behavior can be overridden providing `s_max` as explained in ``Arguments``. Parameters grid: LVGridDing0 LV grid data Arguments --------- s_max : dict dict containing maximum apparent power of load or generation case and str describing the case. For example .. code-block:: python { 's_max': 480, 'case': 'load' } or .. code-block:: python { 's_max': 120, 'case': 'gen' } s_max passed overrides `grid.grid_district.peak_load` respectively `grid.station().peak_generation`. Returns ------- :pandas:`pandas.DataFrame<dataframe>` Parameters of chosen Transformer :obj:`int` Count of transformers Notes ----- The LV transformer with the next higher available nominal apparent power is chosen. Therefore, a max. allowed transformer loading of 100% is implicitly assumed. If the peak load exceeds the max. power of a single available transformer, use multiple trafos. """


    load_factor_lv_trans_lc_normal = cfg_ding0.get('assumptions',
                                                   'load_factor_lv_trans_lc_normal')
    load_factor_lv_trans_fc_normal = cfg_ding0.get('assumptions',
                                                   'load_factor_lv_trans_fc_normal')

    cos_phi_load = cfg_ding0.get('assumptions',
                                 'cos_phi_load')
    cos_phi_gen = cfg_ding0.get('assumptions',
                                'cos_phi_gen')

    # get equipment parameters of LV transformers
    trafo_parameters = grid.network.static_data['LV_trafos']

    # determine s_max from grid object if not provided via arguments
    if s_max is None:
        # get maximum from peak load and peak generation
        s_max_load = grid.grid_district.peak_load / cos_phi_load
        s_max_gen = grid.station().peak_generation / cos_phi_gen

        # check if load or generation is greater respecting corresponding load factor
        if s_max_load > s_max_gen:
            # use peak load and load factor from load case
            load_factor_lv_trans = load_factor_lv_trans_lc_normal
            s_max = s_max_load
        else:
            # use peak generation and load factor for feedin case
            load_factor_lv_trans = load_factor_lv_trans_fc_normal
            s_max = s_max_gen
    else:
        if s_max['case'] == 'load':
            load_factor_lv_trans = load_factor_lv_trans_lc_normal
        elif s_max['case'] == 'gen':
            load_factor_lv_trans = load_factor_lv_trans_fc_normal
        else:
            logger.error('No proper \'case\' provided for argument s_max')
            raise ValueError('Please provide proper \'case\' for argument '
                             '`s_max`.')
        s_max = s_max['s_max']

    # get max. trafo
    transformer_max = trafo_parameters.iloc[trafo_parameters['S_nom'].idxmax()]

    # peak load is smaller than max. available trafo
    if s_max < (transformer_max['S_nom'] * load_factor_lv_trans ):
        # choose trafo
        transformer = trafo_parameters.iloc[
            trafo_parameters[
                trafo_parameters['S_nom'] * load_factor_lv_trans > s_max][
                'S_nom'].idxmin()]
        transformer_cnt = 1
    # peak load is greater than max. available trafo -> use multiple trafos
    else:
        transformer_cnt = 2
        # increase no. of trafos until peak load can be supplied
        while not any(trafo_parameters['S_nom'] * load_factor_lv_trans > (
                    s_max / transformer_cnt)):
            transformer_cnt += 1
        transformer = trafo_parameters.iloc[
            trafo_parameters[
                trafo_parameters['S_nom'] * load_factor_lv_trans
                > (s_max / transformer_cnt)]['S_nom'].idxmin()]

    return transformer, transformer_cnt