docstr: Create model from dataset.
  
  Args:
      dataset: timeseries dataset
      allowed_encoder_known_variable_names: List of known variables that are allowed in encoder, defaults to all
      **kwargs: additional arguments such as hyperparameters for model (see ``__init__()``)
  
  Returns:
      DeepAR network
docstr_tok: ["Create","model","from","dataset",".","Args",":","dataset",":","timeseries","dataset","allowed_encoder_known_variable_names",":","List","of","known","variables","that","are","allowed","in","encoder",",","defaults","to","all","*","*","kwargs",":","additional","arguments","such","as","hyperparameters","for","model","(","see","``","__init__","(",")","``",")","Returns",":","DeepAR","network"]
code: def from_dataset(
      cls,
      dataset: TimeSeriesDataSet,
      allowed_encoder_known_variable_names: List[str] = None,
      **kwargs,
  ):
      """
      Create model from dataset.
  
      Args:
          dataset: timeseries dataset
          allowed_encoder_known_variable_names: List of known variables that are allowed in encoder, defaults to all
          **kwargs: additional arguments such as hyperparameters for model (see ``__init__()``)
  
      Returns:
          DeepAR network
      """
      new_kwargs = {}
      if dataset.multi_target:
          new_kwargs.setdefault(
              "loss",
              MultiLoss(
                  [NormalDistributionLoss()] * len(dataset.target_names)
              ),
          )
      new_kwargs.update(kwargs)
      assert not isinstance(
          dataset.target_normalizer, NaNLabelEncoder
      ) and (
          not isinstance(dataset.target_normalizer, MultiNormalizer)
          or all(
              [
                  not isinstance(normalizer, NaNLabelEncoder)
                  for normalizer in dataset.target_normalizer
              ]
          )
      ), "target(s) should be continuous - categorical targets are not supported"  # todo: remove this restriction
      if isinstance(
          new_kwargs.get("loss", None), MultivariateDistributionLoss
      ):
          assert (
              dataset.min_prediction_length
              == dataset.max_prediction_length
          ), "Multivariate models require constant prediction lenghts"
      return super().from_dataset(
          dataset,
          allowed_encoder_known_variable_names=allowed_encoder_known_variable_names,
          **new_kwargs,
      )
  
imports: from copy import copy, deepcopy
  from typing import Any, Dict, List, Literal, Optional, Tuple, Union
  import numpy
  import pandas
  import torch
  import torch.nn
  from torch.utils.data.dataloader import DataLoader
  from pytorch_forecasting.data.encoders import EncoderNormalizer, MultiNormalizer, NaNLabelEncoder
  from pytorch_forecasting.data.timeseries import TimeSeriesDataSet
  from pytorch_forecasting.metrics import MAE, MAPE, MASE, RMSE, SMAPE, DistributionLoss, Metric, MultiLoss, MultivariateDistributionLoss, NormalDistributionLoss
  from pytorch_forecasting.models.base_model import AutoRegressiveBaseModelWithCovariates, Prediction
  from pytorch_forecasting.models.nn import HiddenState, MultiEmbedding, get_rnn
  from pytorch_forecasting.utils import apply_to_list, to_list
label_desc: Use image node_id 2 for calling the DeepAR obj's underlying member method code with example usage: obj.from_dataset(cls, dataset, allowed_encoder_known_variable_names) and returns: super