class_docstr: A generic LightningMoudle for light-weight HPO.
docstr: Create LightningModule that exposes hyper parameters in init arguments.
  
  :param model_creator:   the model creator function.
  :param model_config:    model related configurations - argument of model_creator.
  :param data_config:     data related configurations - argument of model_creator.
  :param optim_creator:   the optimizer creator function.
  :param optim_config:    optim configurations - argument of optim_creator.
  :param loss_creator:    the loss creator function.
  :param loss_config:     the loss configurations - argument of loss_creator.
  :param data:            the train data
  :param validation_data: validation data required at present.
  :param scheduler:       learning rate scheduler.
  :param metrics:         list of metrics to calculate accuracy of the model.
docstr_tok: ["Create","LightningModule","that","exposes","hyper","parameters","in","init","arguments",".",":","param","model_creator",":","the","model","creator","function",".",":","param","model_config",":","model","related","configurations","-","argument","of","model_creator",".",":","param","data_config",":","data","related","configurations","-","argument","of","model_creator",".",":","param","optim_creator",":","the","optimizer","creator","function",".",":","param","optim_config",":","optim","configurations","-","argument","of","optim_creator",".",":","param","loss_creator",":","the","loss","creator","function",".",":","param","loss_config",":","the","loss","configurations","-","argument","of","loss_creator",".",":","param","data",":","the","train","data",":","param","validation_data",":","validation","data","required","at","present",".",":","param","scheduler",":","learning","rate","scheduler",".",":","param","metrics",":","list","of","metrics","to","calculate","accuracy","of","the","model","."]
code: def __init__(
      self,
      model_creator,
      optim_creator,
      loss_creator,
      data,
      validation_data=None,
      batch_size=32,
      epochs=1,
      metrics: List[Metric] = None,
      scheduler: _LRScheduler = None,
      num_processes=1,
      model_config_keys=None,
      data_config_keys=None,
      optim_config_keys=None,
      loss_config_keys=None,
      **all_config,
  ):
      """
      Create LightningModule that exposes hyper parameters in init arguments.
  
      :param model_creator:   the model creator function.
      :param model_config:    model related configurations - argument of model_creator.
      :param data_config:     data related configurations - argument of model_creator.
      :param optim_creator:   the optimizer creator function.
      :param optim_config:    optim configurations - argument of optim_creator.
      :param loss_creator:    the loss creator function.
      :param loss_config:     the loss configurations - argument of loss_creator.
      :param data:            the train data
      :param validation_data: validation data required at present.
      :param scheduler:       learning rate scheduler.
      :param metrics:         list of metrics to calculate accuracy of the model.
      """
      self.data = data
      self.validation_data = validation_data
      # set batch size
  
      if batch_size % num_processes != 0:
          warnings.warn(
              "'batch_size' cannot be divided with no remainder by "
              "'num_processes'. We got 'batch_size' = {} and "
              "'num_processes' = {}".format(batch_size, num_processes)
          )
      self.batch_size = max(1, batch_size // num_processes)
      self.epochs = epochs
  
      model_config = self._get_config_by_keys(
          model_config_keys, all_config
      )
      data_config = self._get_config_by_keys(
          data_config_keys, all_config
      )
      optim_config = self._get_config_by_keys(
          optim_config_keys, all_config
      )
      loss_config = self._get_config_by_keys(
          loss_config_keys, all_config
      )
  
      model = model_creator({**model_config, **data_config})
      loss = loss_creator(loss_config)
      optimizer = optim_creator(model, optim_config)
  
      invalidInputError(
          isinstance(model, nn.Module)
          and not isinstance(model, pl.LightningModule),
          "The created model must be instance of nn.Module but got {}".format(
              model.__class__
          ),
      )
  
      super().__init__(
          model=model,
          loss=loss,
          optimizer=optimizer,
          scheduler=scheduler,
          metrics=metrics,
      )
  
      _check_duplicate_metrics(self.metrics)
      self.save_hyperparameters(
          ignore=[
              "model_creator",
              "optim_creator",
              "loss_creator",
              "model_config_keys",
              "data_config_keys",
              "optim_config_keys",
              "loss_config_keys",
              "data",
              "validation_data",
              "metrics",
          ]
      )
  
imports: from bigdl.nano.pytorch.lightning import LightningModule
  from bigdl.nano.utils.common import invalidInputError
  from typing import List
  import pytorch_lightning
  from torchmetrics.metric import Metric
  from torch.optim.lr_scheduler import _LRScheduler
  import bigdl.nano.automl.hpo
  import warnings
  import torch
  import inspect
  from torch import nn, Tensor, fx
  from torch.utils.data import TensorDataset, DataLoader
  from bigdl.nano.automl.hpo.space import Space
label_desc: Use image node_id 1 to create a new GenericLightningModule object from inherited base classes: LightningModule with example: obj = GenericLightningModule(model_creator, optim_creator, loss_creator, data, validation_data, batch_size, epochs, metrics, scheduler, num_processes, model_config_keys, data_config_keys, optim_config_keys, loss_config_keys)