code: def __init__(
      self,
      *,
      states,
      actions,
      l2_regularization,
      parallel_interactions,
      config,
      saver,
      summarizer,
      tracking,
  ):
      # Initialize global registries
      setattr(Module, "_MODULE_STACK", list())
      setattr(Layer, "_REGISTERED_LAYERS", OrderedDict())
  
      # Tensorforce config
      self._config = config
  
      Module._MODULE_STACK.clear()
      Module._MODULE_STACK.append(self.__class__)
  
      super().__init__(
          device=self._config.device,
          l2_regularization=l2_regularization,
          name=self._config.name,
      )
  
      assert self.l2_regularization is not None
      self.is_trainable = True
      self.is_saved = True
  
      # Keep track of tensor names to check for collisions
      self.value_names = set()
  
      # Terminal specification
      self.terminal_spec = TensorSpec(
          type="int", shape=(), num_values=3
      )
      self.value_names.add("terminal")
  
      # Reward specification
      self.reward_spec = TensorSpec(type="float", shape=())
      self.value_names.add("reward")
  
      # Parallel specification
      self.parallel_spec = TensorSpec(
          type="int", shape=(), num_values=parallel_interactions
      )
      self.value_names.add("parallel")
  
      # Deterministic specification
      self.deterministic_spec = TensorSpec(type="bool", shape=())
      self.value_names.add("deterministic")
  
      # State space specification
      self.states_spec = states
      for name, spec in self.states_spec.items():
          name = "" if name is None else " " + name
          if spec.type != "float":
              continue
          elif spec.min_value is None:
              logging.warning(
                  "No min_value bound specified for state{}.".format(
                      name
                  )
              )
          elif np.isinf(spec.min_value).any():
              logging.warning(
                  "Infinite min_value bound for state{}.".format(name)
              )
          elif spec.max_value is None:
              logging.warning(
                  "No max_value bound specified for state{}.".format(
                      name
                  )
              )
          elif np.isinf(spec.max_value).any():
              logging.warning(
                  "Infinite max_value bound for state{}.".format(name)
              )
  
      # Check for name collisions
      if self.states_spec.is_singleton():
          if "state" in self.value_names:
              raise TensorforceError.exists(
                  name="value name", value=name
              )
          self.value_names.add("state")
      else:
          for name in self.states_spec:
              if name in self.value_names:
                  raise TensorforceError.exists(
                      name="value name", value=name
                  )
              self.value_names.add(name)
  
      # Action space specification
      self.actions_spec = actions
      for name, spec in self.actions_spec.items():
          name = "" if name is None else " " + name
          if spec.type != "float":
              continue
          elif spec.min_value is None:
              logging.warning(
                  "No min_value specified for action{}.".format(name)
              )
          elif np.isinf(spec.min_value).any():
              raise TensorforceError(
                  "Infinite min_value bound for action{}.".format(name)
              )
          elif spec.max_value is None:
              logging.warning(
                  "No max_value specified for action{}.".format(name)
              )
          elif np.isinf(spec.max_value).any():
              raise TensorforceError(
                  "Infinite max_value bound for action{}.".format(name)
              )
  
      # Check for name collisions
      if self.actions_spec.is_singleton():
          if "action" in self.value_names:
              raise TensorforceError.exists(
                  name="value name", value=name
              )
          self.value_names.add("action")
      else:
          for name in self.actions_spec:
              if name in self.value_names:
                  raise TensorforceError.exists(
                      name="value name", value=name
                  )
              self.value_names.add(name)
  
      # Internal state space specification
      self.internals_spec = TensorsSpec()
      self.initial_internals = ArrayDict()
  
      # Auxiliary value space specification
      self.auxiliaries_spec = TensorsSpec()
      for name, spec in self.actions_spec.items():
          if (
              self.config.enable_int_action_masking
              and spec.type == "int"
              and spec.num_values is not None
          ):
              self.auxiliaries_spec[name] = TensorsSpec(
                  mask=TensorSpec(
                      type="bool",
                      shape=(spec.shape + (spec.num_values,)),
                  )
              )
  
      # Parallel interactions
      assert (
          isinstance(parallel_interactions, int)
          and parallel_interactions >= 1
      )
      self.parallel_interactions = parallel_interactions
  
      # Saver
      if isinstance(saver, str):
          saver = dict(directory=saver)
      if saver is None:
          self.saver = None
      elif not all(
          key
          in (
              "directory",
              "filename",
              "frequency",
              "load",
              "max_checkpoints",
              "max_hour_frequency",
              "unit",
          )
          for key in saver
      ):
          raise TensorforceError.value(
              name="agent",
              argument="saver",
              value=list(saver),
              hint="not from {directory,filename,frequency,load,max_checkpoints,"
              "max_hour_frequency,unit}",
          )
      elif "directory" not in saver:
          raise TensorforceError.required(
              name="agent", argument="saver[directory]"
          )
      else:
          self.saver = dict(saver)
  
      # Summarizer
      if isinstance(summarizer, str):
          summarizer = dict(directory=summarizer)
      if summarizer is None:
          self.summarizer = None
          self.summaries = frozenset()
      elif not all(
          key
          in (
              "directory",
              "filename",
              "flush",
              "max_summaries",
              "summaries",
          )
          for key in summarizer
      ):
          raise TensorforceError.value(
              name="agent",
              argument="summarizer",
              value=list(summarizer),
              hint="not from {directory,filename,flush,max_summaries,summaries}",
          )
      elif "directory" not in summarizer:
          raise TensorforceError.required(
              name="agent", argument="summarizer[directory]"
          )
      else:
          self.summarizer = dict(summarizer)
  
          # Summary labels
          summaries = summarizer.get("summaries")
          if summaries is None or summaries == "all":
              self.summaries = "all"
          elif not all(isinstance(label, str) for label in summaries):
              raise TensorforceError.value(
                  name="agent",
                  argument="summarizer[summaries]",
                  value=summaries,
              )
          else:
              self.summaries = frozenset(summaries)
  
      # Tracking
      if tracking is None:
          self.tracking = frozenset()
      elif tracking == "all":
          self.tracking = "all"
      else:
          self.tracking = frozenset(tracking)
  
imports: from collections import OrderedDict
  import logging
  import os
  import time
  import h5py
  import numpy
  import tensorflow
  from tensorforce import TensorforceError
  from tensorforce.core import ArrayDict, Module, SignatureDict, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util, VariableDict
  from tensorforce.core.layers import Layer
label_desc: Use image node_id 1 to create a new Model object from inherited base classes: Module with example: obj = Model()