Q: how to get the arguments in the train function I want to get the arguments from the parse_args() in the train function. It is giving error as this
ipykernel_launcher.py: error: the following arguments are required: --dataset
import argparse
import torch
from torchsummary import summary

def parse_args():
    # Training settings
    parser = argparse.ArgumentParser(description='Training Settings')
    parser.add_argument("--num_class", type=int, default=1)
    parser.add_argument("--k_shot", type=int, default=5)
    parser.add_argument("--batch_size", type=int, default=16)
    parser.add_argument("--num_episode", type=int, default=500000)
    parser.add_argument("--test_episode", type=int, default=2000)
    parser.add_argument("--lr", type=float, default=0.001)
    parser.add_argument("--gpu", type=int, default=0)
    parser.add_argument("--dataset", type=int, default=None, required=True)
    parser.add_argument("--finetune", type=bool, default=True)

   opt = parser.parse_args()
   return opt


def train():
    args = parse_args()
    k_shot = args.k_shot
    model = SegmentationModel("efficientnet-b7")
    model.cuda()

train()


A: You can always pass a list of arguments to parse_args:
def train(args):
    args = parse_args(args)
    k_shot = args.k_shot
    model = SegmentationModel("efficientnet-b7")
    model.cuda()

Then do:
>>> train(['--dataset', 'mnist'])

