docstr: Create an online DiscreteDQN Policy from env.
docstr_tok: ["Create","an","online","DiscreteDQN","Policy","from","env","."]
code: def create_policy(
      self,
      trainer_module: ReAgentLightningModule,
      serving: bool = False,
      normalization_data_map: Optional[
          Dict[str, NormalizationData]
      ] = None,
  ):
      """Create an online DiscreteDQN Policy from env."""
  
      # FIXME: this only works for one-hot encoded actions
      action_dim = trainer_module.q_network.input_prototype()[
          1
      ].float_features.shape[1]
      if serving:
          assert normalization_data_map
          return create_predictor_policy_from_model(
              self.build_serving_module(
                  trainer_module, normalization_data_map
              ),
              max_num_actions=action_dim,
          )
      else:
          # pyre-fixme[16]: `ParametricDQNBase` has no attribute `rl_parameters`.
          sampler = SoftmaxActionSampler(
              temperature=self.rl_parameters.temperature
          )
          scorer = parametric_dqn_scorer(
              max_num_actions=action_dim,
              q_network=trainer_module.q_network,
          )
          return Policy(scorer=scorer, sampler=sampler)
  
imports: import logging
  from dataclasses import replace
  from typing import Dict, List, Optional, Tuple
  import reagent.core.types
  from reagent.core.dataclasses import dataclass, field
  from reagent.core.parameters import EvaluationParameters, NormalizationData, NormalizationKey
  from reagent.data.data_fetcher import DataFetcher
  from reagent.data.manual_data_module import ManualDataModule
  from reagent.gym.policies.policy import Policy
  from reagent.gym.policies.predictor_policies import create_predictor_policy_from_model
  from reagent.gym.policies.samplers.discrete_sampler import SoftmaxActionSampler
  from reagent.gym.policies.scorers.discrete_scorer import parametric_dqn_scorer
  from reagent.model_managers.model_manager import ModelManager
  from reagent.models.base import ModelBase
  from reagent.preprocessing.batch_preprocessor import BatchPreprocessor
  from reagent.preprocessing.normalization import get_feature_config
  from reagent.preprocessing.types import InputColumn
  from reagent.training import ReAgentLightningModule
  from reagent.workflow.identify_types_flow import identify_normalization_parameters
  from reagent.workflow.types import Dataset, PreprocessingOptions, ReaderOptions, RewardOptions, TableSpec
label_desc: Use image node_id 2 for calling the ParametricDQNBase obj's underlying member method code with example usage: obj.create_policy(trainer_module, serving, normalization_data_map) and returns: create_predictor_policy_from_model, Policy