class_docstr: Base Model configuration
  Args:
      task (str): Specify whether the problem is regression or classification. `backbone` is a task which
              considers the model as a backbone to generate features. Mostly used internally for SSL and related
              tasks.. Choices are: [`regression`,`classification`,`backbone`].
  
      head (Optional[str]): The head to be used for the model. Should be one of the heads defined in
              `pytorch_tabular.models.common.heads`. Defaults to  LinearHead. Choices are:
              [`None`,`LinearHead`,`MixtureDensityHead`].
  
      head_config (Optional[Dict]): The config as a dict which defines the head. If left empty, will be
              initialized as default linear head.
  
      embedding_dims (Optional[List]): The dimensions of the embedding for each categorical column as a
              list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of
              the categorical column using the rule min(50, (x + 1) // 2)
  
      embedding_dropout (float): Dropout to be applied to the Categorical Embedding. Defaults to 0.0
  
      batch_norm_continuous_input (bool): If True, we will normalize the continuous layer by passing it
              through a BatchNorm layer.
  
      virtual_batch_size (Optional[int]): If not None, all BatchNorms will be converted to GhostBatchNorm's
              with the specified virtual batch size. Defaults to None
  
      learning_rate (float): The learning rate of the model. Defaults to 1e-3.
  
      loss (Optional[str]): The loss function to be applied. By Default, it is MSELoss for regression and
              CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss
              or L1Loss for regression and CrossEntropyLoss for classification
  
      metrics (Optional[List[str]]): the list of metrics you need to track during training. The metrics
              should be one of the functional metrics implemented in ``torchmetrics``. By default, it is
              accuracy if classification and mean_squared_error for regression
  
      metrics_prob_input (Optional[bool]): Is a mandatory parameter for classification metrics defined in
              the config. This defines whether the input to the metric function is the probability or the class.
              Length should be same as the number of metrics. Defaults to None.
  
      metrics_params (Optional[List]): The parameters to be passed to the metrics function. `task` is forced to
              be `multiclass` because the multiclass version can handle binary as well and for simplicity we are
              only using `multiclass`.
  
      target_range (Optional[List]): The range in which we should limit the output variable. Currently
              ignored for multi-target regression. Typically used for Regression problems. If left empty, will
              not apply any restrictions
  
      seed (int): The seed for reproducibility. Defaults to 42
class_docstr_tok: ["Base","Model","configuration","Args",":","task","(","str",")",":","Specify","whether","the","problem","is","regression","or","classification",".","`","backbone","`","is","a","task","which","considers","the","model","as","a","backbone","to","generate","features",".","Mostly","used","internally","for","SSL","and","related","tasks","..","Choices","are",":","[","`","regression","`",",","`","classification","`",",","`","backbone","`","]",".","head","(","Optional","[","str","]",")",":","The","head","to","be","used","for","the","model",".","Should","be","one","of","the","heads","defined","in","`","pytorch_tabular.models.common.heads","`",".","Defaults","to","LinearHead",".","Choices","are",":","[","`","None","`",",","`","LinearHead","`",",","`","MixtureDensityHead","`","]",".","head_config","(","Optional","[","Dict","]",")",":","The","config","as","a","dict","which","defines","the","head",".","If","left","empty",",","will","be","initialized","as","default","linear","head",".","embedding_dims","(","Optional","[","List","]",")",":","The","dimensions","of","the","embedding","for","each","categorical","column","as","a","list","of","tuples","(","cardinality",",","embedding_dim",")",".","If","left","empty",",","will","infer","using","the","cardinality","of","the","categorical","column","using","the","rule","min","(","50",",","(","x","+","1",")","\/\/","2",")","embedding_dropout","(","float",")",":","Dropout","to","be","applied","to","the","Categorical","Embedding",".","Defaults","to","0.0","batch_norm_continuous_input","(","bool",")",":","If","True",",","we","will","normalize","the","continuous","layer","by","passing","it","through","a","BatchNorm","layer",".","virtual_batch_size","(","Optional","[","int","]",")",":","If","not","None",",","all","BatchNorms","will","be","converted","to","GhostBatchNorm's","with","the","specified","virtual","batch","size",".","Defaults","to","None","learning_rate","(","float",")",":","The","learning","rate","of","the","model",".","Defaults","to","1e-3",".","loss","(","Optional","[","str","]",")",":","The","loss","function","to","be","applied",".","By","Default",",","it","is","MSELoss","for","regression","and","CrossEntropyLoss","for","classification",".","Unless","you","are","sure","what","you","are","doing",",","leave","it","at","MSELoss","or","L1Loss","for","regression","and","CrossEntropyLoss","for","classification","metrics","(","Optional","[","List","[","str","]","]",")",":","the","list","of","metrics","you","need","to","track","during","training",".","The","metrics","should","be","one","of","the","functional","metrics","implemented","in","``","torchmetrics","``",".","By","default",",","it","is","accuracy","if","classification","and","mean_squared_error","for","regression","metrics_prob_input","(","Optional","[","bool","]",")",":","Is","a","mandatory","parameter","for","classification","metrics","defined","in","the","config",".","This","defines","whether","the","input","to","the","metric","function","is","the","probability","or","the","class",".","Length","should","be","same","as","the","number","of","metrics",".","Defaults","to","None",".","metrics_params","(","Optional","[","List","]",")",":","The","parameters","to","be","passed","to","the","metrics","function",".","`","task","`","is","forced","to","be","`","multiclass","`","because","the","multiclass","version","can","handle","binary","as","well","and","for","simplicity","we","are","only","using","`","multiclass","`",".","target_range","(","Optional","[","List","]",")",":","The","range","in","which","we","should","limit","the","output","variable",".","Currently","ignored","for","multi-target","regression",".","Typically","used","for","Regression","problems",".","If","left","empty",",","will","not","apply","any","restrictions","seed","(","int",")",":","The","seed","for","reproducibility",".","Defaults","to","42"]
code: def __post_init__(self):
      if self.task == "regression":
          self.loss = self.loss or "MSELoss"
          self.metrics = self.metrics or ["mean_squared_error"]
          self.metrics_params = (
              [{} for _ in self.metrics]
              if self.metrics_params is None
              else self.metrics_params
          )
          self.metrics_prob_input = [
              False for _ in self.metrics
          ]  # not used in Regression. just for compatibility
      elif self.task == "classification":
          self.loss = self.loss or "CrossEntropyLoss"
          self.metrics = self.metrics or ["accuracy"]
          self.metrics_params = (
              [{} for _ in self.metrics]
              if self.metrics_params is None
              else self.metrics_params
          )
          self.metrics_prob_input = (
              [False for _ in self.metrics]
              if self.metrics_prob_input is None
              else self.metrics_prob_input
          )
      elif self.task == "backbone":
          self.loss = None
          self.metrics = None
          self.metrics_params = None
          if self.head is not None:
              logger.warning(
                  "`head` is not a valid parameter for backbone task. Making `head=None`"
              )
              self.head = None
              self.head_config = None
      else:
          raise NotImplementedError(
              f"{self.task} is not a valid task. Should be one of "
              f"{self.__dataclass_fields__['task'].metadata['choices']}"
          )
      if self.metrics is not None:
          assert len(self.metrics) == len(
              self.metrics_params
          ), "metrics and metric_params should have same length"
  
      if self.task != "backbone":
          assert self.head in dir(
              heads.blocks
          ), f"{self.head} is not a valid head"
          _head_callable = getattr(heads.blocks, self.head)
          ideal_head_config = _head_callable._config_template
          invalid_keys = set(self.head_config.keys()) - set(
              ideal_head_config.__dict__.keys()
          )
          assert (
              len(invalid_keys) == 0
          ), f"`head_config` has some invalid keys: {invalid_keys}"
  
      # For Custom models, setting these values for compatibility
      if not hasattr(self, "_config_name"):
          self._config_name = type(self).__name__
      if not hasattr(self, "_model_name"):
          self._model_name = re.sub(
              "[Cc]onfig", "Model", self._config_name
          )
      if not hasattr(self, "_backbone_name"):
          self._backbone_name = re.sub(
              "[Cc]onfig", "Backbone", self._config_name
          )
      _validate_choices(self)
  
imports: import os
  import re
  from dataclasses import MISSING, dataclass, field
  from typing import Any, Dict, Iterable, List, Optional
  from omegaconf import OmegaConf
  from pytorch_tabular.models.common import heads
  from pytorch_tabular.utils import get_logger
label_desc: Use image node_id 1 for calling the ModelConfig obj's underlying member method code with example usage: obj.__post_init__() without return types