import os
import sys
import torch
import yaml
from functools import partial
sys.path.append('../../../../')
from trainers import trainer, frn_train
from datasets import dataloaders
from models.FRN import FRN


args = trainer.train_parser()
with open('../../../../config.yml', 'r') as f:
    temp = yaml.safe_load(f)
data_path = os.path.abspath(temp['data_path'])
fewshot_path = os.path.join(data_path,'CUB_fewshot_raw')

pm = trainer.Path_Manager(fewshot_path=fewshot_path,args=args)

train_way = args.train_way
shots = [args.train_shot, args.train_query_shot]

train_loader = dataloaders.meta_train_dataloader(data_path=pm.train,
                                                way=train_way,
                                                shots=shots,
                                                transform_type=args.train_transform_type)

model = FRN(way=train_way,
            shots=[args.train_shot, args.train_query_shot],
            resnet=args.resnet)

train_func = partial(frn_train.default_train,train_loader=train_loader)

tm = trainer.Train_Manager(args,path_manager=pm,train_func=train_func)

tm.train(model)

tm.evaluate(model)
[((76, 107), 'sys.path.append', 'sys.path.append', (['"""../../../../"""'], {}), "('../../../../')\n", (91, 107), False, 'import sys\n'), ((217, 239), 'trainers.trainer.train_parser', 'trainer.train_parser', ([], {}), '()\n', (237, 239), False, 'from trainers import trainer, frn_train\n'), ((328, 362), 'os.path.abspath', 'os.path.abspath', (["temp['data_path']"], {}), "(temp['data_path'])\n", (343, 362), False, 'import os\n'), ((378, 420), 'os.path.join', 'os.path.join', (['data_path', '"""CUB_fewshot_raw"""'], {}), "(data_path, 'CUB_fewshot_raw')\n", (390, 420), False, 'import os\n'), ((426, 484), 'trainers.trainer.Path_Manager', 'trainer.Path_Manager', ([], {'fewshot_path': 'fewshot_path', 'args': 'args'}), '(fewshot_path=fewshot_path, args=args)\n', (446, 484), False, 'from trainers import trainer, frn_train\n'), ((577, 705), 'datasets.dataloaders.meta_train_dataloader', 'dataloaders.meta_train_dataloader', ([], {'data_path': 'pm.train', 'way': 'train_way', 'shots': 'shots', 'transform_type': 'args.train_transform_type'}), '(data_path=pm.train, way=train_way, shots=\n    shots, transform_type=args.train_transform_type)\n', (610, 705), False, 'from datasets import dataloaders\n'), ((854, 945), 'models.FRN.FRN', 'FRN', ([], {'way': 'train_way', 'shots': '[args.train_shot, args.train_query_shot]', 'resnet': 'args.resnet'}), '(way=train_way, shots=[args.train_shot, args.train_query_shot], resnet=\n    args.resnet)\n', (857, 945), False, 'from models.FRN import FRN\n'), ((979, 1038), 'functools.partial', 'partial', (['frn_train.default_train'], {'train_loader': 'train_loader'}), '(frn_train.default_train, train_loader=train_loader)\n', (986, 1038), False, 'from functools import partial\n'), ((1044, 1111), 'trainers.trainer.Train_Manager', 'trainer.Train_Manager', (['args'], {'path_manager': 'pm', 'train_func': 'train_func'}), '(args, path_manager=pm, train_func=train_func)\n', (1065, 1111), False, 'from trainers import trainer, frn_train\n'), ((298, 315), 'yaml.safe_load', 'yaml.safe_load', (['f'], {}), '(f)\n', (312, 315), False, 'import yaml\n')]