class_docstr: Defines an abstract neural network model for use with RLlib.
  
  Custom models should extend either TFModelV2 or TorchModelV2 instead of
  this class directly.
  
  Data flow:
      obs -> forward() -> model_out
          \-> value_function() -> V(s)
class_docstr_tok: ["Defines","an","abstract","neural","network","model","for","use","with","RLlib",".","Custom","models","should","extend","either","TFModelV2","or","TorchModelV2","instead","of","this","class","directly",".","Data","flow",":","obs","-",">","forward","(",")","-",">","model_out","\\-",">","value_function","(",")","-",">","V","(","s",")"]
docstr: Call the model with the given input tensors and state.
  
  This is the method used by RLlib to execute the forward pass. It calls
  forward() internally after unpacking nested observation tensors.
  
  Custom models should override forward() instead of __call__.
  
  Args:
      input_dict: Dictionary of input tensors.
      state: list of state tensors with sizes matching those
          returned by get_initial_state + the batch dimension
      seq_lens: 1D tensor holding input sequence lengths.
  
  Returns:
      A tuple consisting of the model output tensor of size
          [BATCH, output_spec.size] or a list of tensors corresponding to
          output_spec.shape_list, and a list of state tensors of
          [BATCH, state_size_i] if any.
docstr_tok: ["Call","the","model","with","the","given","input","tensors","and","state",".","This","is","the","method","used","by","RLlib","to","execute","the","forward","pass",".","It","calls","forward","(",")","internally","after","unpacking","nested","observation","tensors",".","Custom","models","should","override","forward","(",")","instead","of","__call__",".","Args",":","input_dict",":","Dictionary","of","input","tensors",".","state",":","list","of","state","tensors","with","sizes","matching","those","returned","by","get_initial_state","+","the","batch","dimension","seq_lens",":","1D","tensor","holding","input","sequence","lengths",".","Returns",":","A","tuple","consisting","of","the","model","output","tensor","of","size","[","BATCH",",","output_spec.size","]","or","a","list","of","tensors","corresponding","to","output_spec.shape_list",",","and","a","list","of","state","tensors","of","[","BATCH",",","state_size_i","]","if","any","."]
code: def __call__(
      self,
      input_dict: Union[SampleBatch, ModelInputDict],
      state: List[Any] = None,
      seq_lens: TensorType = None,
  ) -> (TensorType, List[TensorType]):
      """Call the model with the given input tensors and state.
  
      This is the method used by RLlib to execute the forward pass. It calls
      forward() internally after unpacking nested observation tensors.
  
      Custom models should override forward() instead of __call__.
  
      Args:
          input_dict: Dictionary of input tensors.
          state: list of state tensors with sizes matching those
              returned by get_initial_state + the batch dimension
          seq_lens: 1D tensor holding input sequence lengths.
  
      Returns:
          A tuple consisting of the model output tensor of size
              [BATCH, output_spec.size] or a list of tensors corresponding to
              output_spec.shape_list, and a list of state tensors of
              [BATCH, state_size_i] if any.
      """
  
      # Original observations will be stored in "obs".
      # Flattened (preprocessed) obs will be stored in "obs_flat".
  
      # SampleBatch case: Models can now be called directly with a
      # SampleBatch (which also includes tracking-dict case (deprecated now),
      # where tensors get automatically converted).
      if isinstance(input_dict, SampleBatch):
          restored = input_dict.copy(shallow=True)
      else:
          restored = input_dict.copy()
  
      # Backward compatibility.
      if not state:
          state = []
          i = 0
          while "state_in_{}".format(i) in input_dict:
              state.append(input_dict["state_in_{}".format(i)])
              i += 1
      if seq_lens is None:
          seq_lens = input_dict.get(SampleBatch.SEQ_LENS)
  
      # No Preprocessor used: `config._disable_preprocessor_api`=True.
      # TODO: This is unnecessary for when no preprocessor is used.
      #  Obs are not flat then anymore. However, we'll keep this
      #  here for backward-compatibility until Preprocessors have
      #  been fully deprecated.
      if self.model_config.get("_disable_preprocessor_api"):
          restored["obs_flat"] = input_dict["obs"]
      # Input to this Model went through a Preprocessor.
      # Generate extra keys: "obs_flat" (vs "obs", which will hold the
      # original obs).
      else:
          restored["obs"] = restore_original_dimensions(
              input_dict["obs"], self.obs_space, self.framework
          )
          try:
              if len(input_dict["obs"].shape) > 2:
                  restored["obs_flat"] = flatten(
                      input_dict["obs"], self.framework
                  )
              else:
                  restored["obs_flat"] = input_dict["obs"]
          except AttributeError:
              restored["obs_flat"] = input_dict["obs"]
  
      with self.context():
          res = self.forward(restored, state or [], seq_lens)
  
      if isinstance(input_dict, SampleBatch):
          input_dict.accessed_keys = restored.accessed_keys - {
              "obs_flat"
          }
          input_dict.deleted_keys = restored.deleted_keys
          input_dict.added_keys = restored.added_keys - {"obs_flat"}
  
      if (
          not isinstance(res, list) and not isinstance(res, tuple)
      ) or len(res) != 2:
          raise ValueError(
              "forward() must return a tuple of (output, state) tensors, "
              "got {}".format(res)
          )
      outputs, state_out = res
  
      if not isinstance(state_out, list):
          raise ValueError(
              "State output is not a list: {}".format(state_out)
          )
  
      self._last_output = outputs
      return outputs, state_out if len(state_out) > 0 else (state or [])
  
imports: from collections import OrderedDict
  import contextlib
  import gymnasium
  from gymnasium.spaces import Space
  import numpy
  from typing import Dict, List, Any, Union
  from ray.rllib.models.preprocessors import get_preprocessor, RepeatedValuesPreprocessor
  from ray.rllib.models.repeated_values import RepeatedValues
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.policy.view_requirement import ViewRequirement
  from ray.rllib.utils import NullContextManager
  from ray.rllib.utils.annotations import DeveloperAPI, PublicAPI
  from ray.rllib.utils.deprecation import Deprecated
  from ray.rllib.utils.framework import try_import_tf, try_import_torch, TensorType
  from ray.rllib.utils.spaces.repeated import Repeated
  from ray.rllib.utils.typing import ModelConfigDict, ModelInputDict, TensorStructType
label_desc: Use image node_id 7 for calling the ModelV2 obj's underlying member method code with example usage: obj.__call__(input_dict, state, seq_lens) and returns: outputs,  unknown