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)
[((6, 0, 6, 31), 'sys.path.append', 'sys.path.append', ({(6, 16, 6, 30): '"""../../../../"""'}, {}), "('../../../../')", False, 'import sys\n'), ((12, 7, 12, 29), 'trainers.trainer.train_parser', 'trainer.train_parser', ({}, {}), '()', False, 'from trainers import trainer, frn_train\n'), ((15, 12, 15, 46), 'os.path.abspath', 'os.path.abspath', ({(15, 28, 15, 45): "temp['data_path']"}, {}), "(temp['data_path'])", False, 'import os\n'), ((16, 15, 16, 56), 'os.path.join', 'os.path.join', ({(16, 28, 16, 37): 'data_path', (16, 38, 16, 55): '"""CUB_fewshot_raw"""'}, {}), "(data_path, 'CUB_fewshot_raw')", False, 'import os\n'), ((18, 5, 18, 62), 'trainers.trainer.Path_Manager', 'trainer.Path_Manager', (), '', False, 'from trainers import trainer, frn_train\n'), ((23, 15, 26, 89), 'datasets.dataloaders.meta_train_dataloader', 'dataloaders.meta_train_dataloader', (), '', False, 'from datasets import dataloaders\n'), ((28, 8, 30, 31), 'models.FRN.FRN', 'FRN', (), '', False, 'from models.FRN import FRN\n'), ((32, 13, 32, 71), 'functools.partial', 'partial', (), '', False, 'from functools import partial\n'), ((34, 5, 34, 70), 'trainers.trainer.Train_Manager', 'trainer.Train_Manager', (), '', False, 'from trainers import trainer, frn_train\n'), ((14, 11, 14, 28), 'yaml.safe_load', 'yaml.safe_load', ({(14, 26, 14, 27): 'f'}, {}), '(f)', False, 'import yaml\n')]