Optimize code

```
from ENM_class import EnmCli

from parser_utils import parse_eutran_cells, parse_nodeb_pars, parse_nodeb_mo_pars, parse_fea, combine_fea, parse_cosector, clean_cell, clean_band, delete_region, parse_anr_rels
from Baseline import Baseline, compare
from file_write import stat, baseline_write
from collections import Counter
from dotenv import load_dotenv
from remove_old_files import remove_old_files
from mail import send_email
from upload_reports import upload_reports
# from datetime import datetime
load_dotenv('.env')


def enm_main(mo_type, enm):

    command_map = {
        'UtranFreqRelation_prio3_base': ('UtranFreqRelation_prio3_par', Baseline.UtranFreqRelation_prio3_base),
        'UtranFreqRelation_prio4_base': ('UtranFreqRelation_prio4_par', Baseline.UtranFreqRelation_prio4_base),
        'GeranFreqGroupRelation_900_base': ('GeranFreqGroupRelation_900_par', Baseline.GeranFreqGroupRelation_900_base),
        'GeranFreqGroupRelation_1800_base': ('GeranFreqGroupRelation_1800_par', Baseline.GeranFreqGroupRelation_1800_base),
        'UeMeasControl_base': ('UeMeasControl_par', Baseline.UeMeasControl_base),
        'ReportConfigEUtraBestCell_base': ('ReportConfigEUtraBestCell_par', Baseline.ReportConfigEUtraBestCell_base),
        'ReportConfigEUtraIFBestCell_base': ('ReportConfigEUtraIFBestCell_par', Baseline.ReportConfigEUtraIFBestCell_base),
        'ReportConfigB2UtraUlTrig_base': ('ReportConfigB2UtraUlTrig_par', Baseline.ReportConfigB2UtraUlTrig_base),
        'ReportConfigEUtraBestCellAnr_base': ('ReportConfigEUtraBestCellAnr_par', Baseline.ReportConfigEUtraBestCellAnr_base),
        'ReportConfigInterRatLb_base': ('ReportConfigInterRatLb_par', Baseline.ReportConfigInterRatLb_base),
        'EUtranFreqRelation_6250_def': ('EUtranFreqRelation_6250_par', Baseline.EUtranFreqRelation_6250_def),
        'EUtranFreqRelation_1679_def': ('EUtranFreqRelation_1679_par', Baseline.EUtranFreqRelation_1679_def),
    }

    if mo_type == 'BbuENodeBFunctionFea_base':
        enm_bbu_feature = EnmCli.execute_cli_command('BBU_ENodeBFunction_fea', enm)
        bbu_feature_sort = parse_fea(enm_bbu_feature)
        bbu_features = combine_fea(bbu_feature_sort, len(EnmCli.BbuENodeBFunctionFea))
        if bbu_features:
            return compare(bbu_features, Baseline.BbuENodeBFunctionFea_base)
    elif mo_type == 'DusENodeBFunctionFea_base':
        enm_dus_feature = EnmCli.execute_cli_command('DUS_ENodeBFunction_fea', enm)
        dus_feature_sort = parse_fea(enm_dus_feature)
        dus_features = combine_fea(dus_feature_sort, len(EnmCli.DusENodeBFunctionFea))
        if dus_features:
            return compare(dus_features, Baseline.DusENodeBFunctionFea_base)
    elif mo_type == 'ENodeBFunction_base':
        enm_enodebfunction = EnmCli.execute_cli_command('ENodeBFunction_par', enm)
        enodebfunction = parse_nodeb_pars(enm_enodebfunction, EnmCli.ENodeBFunction[-1])
        if enodebfunction:
            return compare(enodebfunction, Baseline.ENodeBFunction_base)
    elif mo_type == 'AnrFunction_base':
        enm_anr = EnmCli.execute_cli_command('AnrFunction_par', enm)
        anr = parse_nodeb_pars(enm_anr, EnmCli.AnrFunction[-1])
        if anr:
            return compare(anr, Baseline.AnrFunction_base)
    elif mo_type == 'AnrFunctionEUtran_base':
        enm_anreutran = EnmCli.execute_cli_command('AnrFunctionEUtran_par', enm)
        anreutran = parse_nodeb_pars(enm_anreutran, EnmCli.AnrFunctionEUtran[-1])
        if anreutran:
            return compare(anreutran, Baseline.AnrFunctionEUtran_base)
    elif mo_type == 'AutoCellCapEstFunction_base':
        enm_autocellcap = EnmCli.execute_cli_command('AutoCellCapEstFunction_par', enm)
        autocellcap = parse_nodeb_pars(enm_autocellcap, EnmCli.AutoCellCapEstFunction[-1])
        if autocellcap:
            return compare(autocellcap, Baseline.AutoCellCapEstFunction_base)
    elif mo_type == 'CarrierAggregationFunction_base':
        enm_carrieraggregation = EnmCli.execute_cli_command('CarrierAggregationFunction_par', enm)
        carrieraggregation = parse_nodeb_pars(enm_carrieraggregation, EnmCli.CarrierAggregationFunction[-1])
        if carrieraggregation:
            return compare(carrieraggregation, Baseline.CarrierAggregationFunction_base)
    elif mo_type == 'LoadBalancingFunction_base':
        enm_loadbalancing = EnmCli.execute_cli_command('LoadBalancingFunction_par', enm)
        loadbalancing = parse_nodeb_pars(enm_loadbalancing, EnmCli.LoadBalancingFunction[-1])
        if loadbalancing:
            return compare(loadbalancing, Baseline.LoadBalancingFunction_base)
    elif mo_type == 'Rcs_base':
        enm_rcs = EnmCli.execute_cli_command('Rcs_par', enm)
        rcs = parse_nodeb_pars(enm_rcs, EnmCli.Rcs[-1])
        if rcs:
            return compare(rcs, Baseline.Rcs_base)
    elif mo_type == 'SectorCarrier_base':
        enm_sectorcarrier = EnmCli.execute_cli_command('SectorCarrier_par', enm)
        sectorcarrier = parse_nodeb_mo_pars(enm_sectorcarrier, EnmCli.SectorCarrier[-1], 'Sub_SectorCarrier')
        if sectorcarrier:
            return compare(sectorcarrier, Baseline.SectorCarrier_base)
    elif mo_type == 'QciProfilePredefined_traffic_base':
        enm_qci_traffic = EnmCli.execute_cli_command('QciProfilePredefined_9_par', enm) + \
                          EnmCli.execute_cli_command('QciProfilePredefined_7_par', enm)
        qci_traffic = parse_nodeb_mo_pars(enm_qci_traffic, EnmCli.QciProfilePredefined[-1], 'Sub_QciProfilePredefined')
        if qci_traffic:
            return compare(qci_traffic, Baseline.QciProfilePredefined_traffic_base)
    elif mo_type == 'ReportConfigEUtraInterFreqLb_800_base':
        enm_uemeas_interlb = EnmCli.execute_cli_command('ReportConfigEUtraInterFreqLb_par1', enm)
        uemeas_interlb = parse_nodeb_mo_pars(enm_uemeas_interlb, EnmCli.ReportConfigEUtraInterFreqLb1[-1],'Sub_EUtranCellFDD')
        uemeas_interlb_cleaned = clean_cell(uemeas_interlb)
        uemeas_interlb_cleaned_800 = clean_band(uemeas_interlb_cleaned, '800')
        if uemeas_interlb_cleaned_800:
            return compare(uemeas_interlb_cleaned_800, Baseline.ReportConfigEUtraInterFreqLb_800_base)
    elif mo_type == 'ReportConfigEUtraInterFreqLb_2100_base':
        enm_uemeas_interlb = EnmCli.execute_cli_command('ReportConfigEUtraInterFreqLb_par1', enm)
        uemeas_interlb = parse_nodeb_mo_pars(enm_uemeas_interlb, EnmCli.ReportConfigEUtraInterFreqLb1[-1],'Sub_EUtranCellFDD')
        uemeas_interlb_cleaned = clean_cell(uemeas_interlb)
        uemeas_interlb_cleaned_2100 = clean_band(uemeas_interlb_cleaned, '2100')
        if uemeas_interlb_cleaned_2100:
            return compare(uemeas_interlb_cleaned_2100, Baseline.ReportConfigEUtraInterFreqLb_2100_base)
    elif mo_type == 'EUtranCellRelationCosite_base':
        enm_cellrel_old = EnmCli.execute_cli_command('EUtranCellRelationCosite_par_old', enm)
        enm_cellrel_new = EnmCli.execute_cli_command('EUtranCellRelationCosite_par_new', enm)
        cellrel = parse_nodeb_mo_pars(enm_cellrel_old + enm_cellrel_new, EnmCli.EUtranCellRelationCosite[-1], 'Sub_EUtranCellFDD')
        cosite_cellrel_cleaned = clean_cell(cellrel)
        if cosite_cellrel_cleaned:
            return compare(cosite_cellrel_cleaned, Baseline.EUtranCellRelationCosite_base)
    elif mo_type == 'EUtranCellRelationCosector_base':
        enm_scell_old = EnmCli.execute_cli_command('EUtranCellRelationCosector_par_old', enm)
        enm_scell_new = EnmCli.execute_cli_command('EUtranCellRelationCosector_par_new', enm)
        enm_scell_anr = EnmCli.execute_cli_command('EUtranCellRelation_anr_scell_par', enm)
        scell_cellrel = parse_nodeb_mo_pars(enm_scell_old + enm_scell_new, EnmCli.EUtranCellRelationCosector[-1], 'Sub_EUtranCellFDD')
        scell_wrong = parse_anr_rels(enm_scell_anr, EnmCli.EUtranCellRelationCosector[-1], 'Sub_EUtranCellFDD')
        cosector_cellrel = parse_cosector(scell_cellrel + scell_wrong)
        if cosector_cellrel:
            return compare(cosector_cellrel, Baseline.EUtranCellRelationCosector_base)
# NON_SHYM
    elif mo_type == 'EUtranCellFDD_def':
        enm_eutrancell = EnmCli.execute_cli_command('EUtranCellFDD_par', enm)
        eutrancell = parse_eutran_cells(enm_eutrancell, EnmCli.EUtranCellFDD[-1])
        eutrancell_cleaned = clean_cell(eutrancell)
        eutrancell_separated = delete_region(eutrancell_cleaned, 'Shymkent')
        if eutrancell_separated:
            return compare(eutrancell_separated, Baseline.EUtranCellFDD_def)
# SHYM
    elif mo_type == 'EUtranCellFDD_shym':
        enm_eutrancell = EnmCli.execute_cli_command('EUtranCellFDD_par_shym2', enm)
        eutrancell = parse_eutran_cells(enm_eutrancell, EnmCli.EUtranCellFDD[-1])
        eutrancell_cleaned = clean_cell(eutrancell)
        if eutrancell_cleaned:
            return compare(eutrancell_cleaned, Baseline.EUtranCellFDD_shym)
    else:
        command, baseline = command_map[mo_type]
        enm_output = EnmCli.execute_cli_command(command, enm)
        list_name = command.split('_')[0]
        parsed_output = parse_nodeb_mo_pars(enm_output, getattr(EnmCli, list_name)[-1], 'Sub_EUtranCellFDD')
        cleaned_output = clean_cell(parsed_output)
        separated_output = delete_region(cleaned_output, 'Shymkent') if 'shym' not in mo_type else cleaned_output
        if separated_output:
            return compare(separated_output, baseline)

base = [name for name, obj in vars(Baseline).items() if isinstance(obj, dict)]

inconslist = []
parslist = []
total_delta = []
output = [enm_main(b, 'ENM_2') for b in base]
```