text: import numpy as np
  import os
  from easydict import EasyDict as edict
  
  config = edict()
  
  config.bn_mom = 0.9
  config.workspace = 256
  config.emb_size = 512
  config.ckpt_embedding = False
  config.net_se = 0
  config.net_act = 'prelu'
  config.net_unit = 3
  config.net_input = 1
  config.net_blocks = [1,4,6,2]
  config.net_output = 'E'
  config.net_multiplier = 1.0
  config.ce_loss = True
  config.fc7_lr_mult = 1.0
  config.fc7_wd_mult = 1.0
  config.fc7_no_bias = False 
  config.max_steps = 0
  config.data_rand_mirror = True
  #config.data_cutoff = 56
  config.data_cutoff = 20
  #config.fetch_size = [32, 112]
  config.fetch_size = None
  config.data_color = 2
  config.data_images_filter = 0
  config.count_flops = True
  config.memonger = False #not work now
  
  
  # network settings
  network = edict()
  
  network.r100 = edict()
  network.r100.net_name = 'fresnet'
  network.r100.num_layers = 100
  
  network.r100fc = edict()
  network.r100fc.net_name = 'fresnet'
  network.r100fc.num_layers = 100
  network.r100fc.net_output = 'FC'
  
  network.r50 = edict()
  network.r50.net_name = 'fresnet'
  network.r50.num_layers = 50
  
  network.r50v1 = edict()
  network.r50v1.net_name = 'fresnet'
  network.r50v1.num_layers = 50
  network.r50v1.net_unit = 1
  
  network.r18 = edict()
  network.r18.net_name = 'fresnet'
  network.r18.num_layers = 18
  
  network.d169 = edict()
  network.d169.net_name = 'fdensenet'
  network.d169.num_layers = 169
  network.d169.per_batch_size = 64
  network.d169.densenet_dropout = 0.0
  
  network.d201 = edict()
  network.d201.net_name = 'fdensenet'
  network.d201.num_layers = 201
  network.d201.per_batch_size = 64
  network.d201.densenet_dropout = 0.0
  
  network.y1 = edict()
  network.y1.net_name = 'fmobilefacenet'
  network.y1.emb_size = 128
  network.y1.net_output = 'GDC'
  
  network.y2 = edict()
  network.y2.net_name = 'fmobilefacenet'
  network.y2.emb_size = 512 
  #network.y2.net_output = 'AGAP'
  network.y2.net_output = 'GDC'
  network.y2.net_blocks = [2,8,16,4]
  
  network.m1 = edict()
  network.m1.net_name = 'fmobilenet'
  network.m1.emb_size = 256
  network.m1.net_output = 'GDC'
  network.m1.net_multiplier = 1.0
  
  network.m05 = edict()
  network.m05.net_name = 'fmobilenet'
  network.m05.emb_size = 256
  network.m05.net_output = 'GDC'
  network.m05.net_multiplier = 0.5
  
  network.mnas = edict()
  network.mnas.net_name = 'fmnasnet'
  network.mnas.emb_size = 256
  network.mnas.net_output = 'GDC'
  network.mnas.net_multiplier = 1.0
  
  network.mnas05 = edict()
  network.mnas05.net_name = 'fmnasnet'
  network.mnas05.emb_size = 256
  network.mnas05.net_output = 'GDC'
  network.mnas05.net_multiplier = 0.5
  
  network.mnas025 = edict()
  network.mnas025.net_name = 'fmnasnet'
  network.mnas025.emb_size = 256
  network.mnas025.net_output = 'GDC'
  network.mnas025.net_multiplier = 0.25
  
  network.shuff = edict()
  network.shuff.net_name = 'shufflenetv2'
  network.shuff.emb_size = 256
  network.shuff.net_output = 'GDC'
  network.shuff.net_multiplier = 2.0
  
  network.shuffse = edict()
  network.shuffse.net_name = 'shufflenetv2'
  network.shuffse.emb_size = 256
  network.shuffse.net_output = 'GDC'
  network.shuffse.net_multiplier = 3.0
  
  # dataset settings
  dataset = edict()
  
  dataset.emore = edict()
  dataset.emore.dataset = 'emore'
  dataset.emore.dataset_path = '../datasets/faces_emore'
  dataset.emore.num_classes = 85742
  dataset.emore.image_shape = (112,112,3)
  dataset.emore.val_targets = ['lfw', 'cfp_fp', 'agedb_30']
  
  dataset.retina = edict()
  dataset.retina.dataset = 'retina'
  dataset.retina.dataset_path = '../datasets/ms1m-retinaface-t1'
  dataset.retina.num_classes = 93431
  dataset.retina.image_shape = (112,112,3)
  dataset.retina.val_targets = ['lfw']
  
  dataset.faceid = edict()
  dataset.faceid.dataset = 'faceid'
  dataset.faceid.dataset_path = '../datasets/FaceID'
  dataset.faceid.num_classes = 93431
  dataset.faceid.image_shape = (112,112,3)
  dataset.faceid.val_targets = []
  
  dataset.ms10k = edict()
  dataset.ms10k.dataset = 'ms10k'
  dataset.ms10k.dataset_path = '../datasets/ms10k'
  dataset.ms10k.num_classes = 10000
  dataset.ms10k.image_shape = (112,112,3)
  dataset.ms10k.val_targets = []
  
  dataset.ms10kp = edict()
  dataset.ms10kp.dataset = 'ms10kp'
  dataset.ms10kp.dataset_path = '../datasets/ms10kp'
  dataset.ms10kp.num_classes = 10001
  dataset.ms10kp.image_shape = (112,112,3)
  dataset.ms10kp.val_targets = []
  
  dataset.anti = edict()
  dataset.anti.dataset = 'anti'
  dataset.anti.dataset_path = '../datasets/anti-spoof'
  dataset.anti.num_classes = 2
  dataset.anti.image_shape = (112,112,3)
  #dataset.anti.image_shape = (112,112,6)
  dataset.anti.val_targets = []
  
  dataset.antift = edict()
  dataset.antift.dataset = 'antift'
  dataset.antift.dataset_path = '../datasets/anti-spoof-ft'
  dataset.antift.num_classes = 2
  dataset.antift.image_shape = (112,112,3)
  dataset.antift.val_targets = []
  
  dataset.antilg = edict()
  dataset.antilg.dataset = 'antilg'
  dataset.antilg.dataset_path = '../datasets/anti-spoof-lg'
  dataset.antilg.num_classes = 2
  dataset.antilg.image_shape = (112,112,3)
  dataset.antilg.val_targets = []
  
  dataset.fqua = edict()
  dataset.fqua.dataset = 'fqua'
  dataset.fqua.dataset_path = '../datasets/face-qua'
  dataset.fqua.num_classes = 2
  dataset.fqua.image_shape = (112,112,3)
  dataset.fqua.val_targets = []
  
  loss = edict()
  loss.softmax = edict()
  loss.softmax.loss_name = 'softmax'
  
  loss.nsoftmax = edict()
  loss.nsoftmax.loss_name = 'margin_softmax'
  loss.nsoftmax.loss_s = 64.0
  loss.nsoftmax.loss_m1 = 1.0
  loss.nsoftmax.loss_m2 = 0.0
  loss.nsoftmax.loss_m3 = 0.0
  
  loss.arcface = edict()
  loss.arcface.loss_name = 'margin_softmax'
  loss.arcface.loss_s = 64.0
  loss.arcface.loss_m1 = 1.0
  loss.arcface.loss_m2 = 0.5
  loss.arcface.loss_m3 = 0.0
  
  loss.cosface = edict()
  loss.cosface.loss_name = 'margin_softmax'
  loss.cosface.loss_s = 64.0
  loss.cosface.loss_m1 = 1.0
  loss.cosface.loss_m2 = 0.0
  loss.cosface.loss_m3 = 0.35
  
  loss.combined = edict()
  loss.combined.loss_name = 'margin_softmax'
  loss.combined.loss_s = 64.0
  loss.combined.loss_m1 = 1.0
  loss.combined.loss_m2 = 0.3
  loss.combined.loss_m3 = 0.2
  
  # default settings
  default = edict()
  
  # default network
  default.network = 'r100'
  default.pretrained = ''
  default.pretrained_epoch = 1
  # default dataset
  default.dataset = 'emore'
  default.loss = 'arcface'
  default.frequent = 100
  default.verbose = 500
  default.kvstore = 'device'
  
  default.end_epoch = 100
  default.lr = 0.1
  default.wd = 0.0005
  default.mom = 0.9
  default.per_batch_size = 128
  default.test_batch_size = 110
  default.ckpt = 2
  #default.lr_steps = '100000,160000,220000'
  default.lr_steps = '10000,16000,22000'
  default.models_root = './models'
  
  
  def generate_config(_network, _dataset, _loss):
      for k, v in loss[_loss].items():
        config[k] = v
        if k in default:
          default[k] = v
      for k, v in network[_network].items():
        config[k] = v
        if k in default:
          default[k] = v
      for k, v in dataset[_dataset].items():
        config[k] = v
        if k in default:
          default[k] = v
      config.loss = _loss
      config.network = _network
      config.dataset = _dataset
      config.num_workers = 8
      if 'DMLC_NUM_WORKER' in os.environ:
        config.num_workers = int(os.environ['DMLC_NUM_WORKER'])
  
  