question: LightningCLI  - instantiate model from config
context: So lets say i have a model and i'm using the newest CLI API to train it: The config uses sub modules and can look something like:
  # config.yaml
  model:
    class_path: pl_models_2.ModelPL
    init_args:
      margin: 0.3
      basemodel:
        class_path: pl_models_2.ModelBackbone
        init_args:
          base_model: resnet50
          pooling: both
  
  data:
    batch_size: 32
    image_size: 224
    augmentation_strategy: medium2
  
  Now i want  to run some scripts  or notebooks using the model i trained with this config and i would like to  instantiate the model using this config file.
  f/e. model = load_model(config.yaml)
  I was digging how this happens in LightningCLI and jsonargsparse but gave up after a while.. and started trying to hack this around with importlib, which works but feels like reinventing the wheel - i mean this logic has to be somewhere already :) i just cant find it.
answer: If you want to use that exact config (not stripping out everything except the model) you can do the following:
  from jsonargparse import ArgumentParser
  
  parser = ArgumentParser()
  parser.add_argument('--model', type=ModelClass)
  parser.add_argument('--data', type=dict) # to ignore data
  config = parser.parse_path('config.yaml')
  config_init = parser.instantiate_classes(config)
  The instantiated model will be in config_init.model.