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: Initializes a ModelV2 instance.
  
  This method should create any variables used by the model.
  
  Args:
      obs_space: Observation space of the target gym
          env. This may have an `original_space` attribute that
          specifies how to unflatten the tensor into a ragged tensor.
      action_space: Action space of the target gym
          env.
      num_outputs: Number of output units of the model.
      model_config: Config for the model, documented
          in ModelCatalog.
      name: Name (scope) for the model.
      framework: Either "tf" or "torch".
docstr_tok: ["Initializes","a","ModelV2","instance",".","This","method","should","create","any","variables","used","by","the","model",".","Args",":","obs_space",":","Observation","space","of","the","target","gym","env",".","This","may","have","an","`","original_space","`","attribute","that","specifies","how","to","unflatten","the","tensor","into","a","ragged","tensor",".","action_space",":","Action","space","of","the","target","gym","env",".","num_outputs",":","Number","of","output","units","of","the","model",".","model_config",":","Config","for","the","model",",","documented","in","ModelCatalog",".","name",":","Name","(","scope",")","for","the","model",".","framework",":","Either","``","tf","''","or","``","torch","''","."]
code: def __init__(
      self,
      obs_space: Space,
      action_space: Space,
      num_outputs: int,
      model_config: ModelConfigDict,
      name: str,
      framework: str,
  ):
      """Initializes a ModelV2 instance.
  
      This method should create any variables used by the model.
  
      Args:
          obs_space: Observation space of the target gym
              env. This may have an `original_space` attribute that
              specifies how to unflatten the tensor into a ragged tensor.
          action_space: Action space of the target gym
              env.
          num_outputs: Number of output units of the model.
          model_config: Config for the model, documented
              in ModelCatalog.
          name: Name (scope) for the model.
          framework: Either "tf" or "torch".
      """
  
      self.obs_space: Space = obs_space
      self.action_space: Space = action_space
      self.num_outputs: int = num_outputs
      self.model_config: ModelConfigDict = model_config
      self.name: str = name or "default_model"
      self.framework: str = framework
      self._last_output = None
      self.time_major = self.model_config.get("_time_major")
      # Basic view requirement for all models: Use the observation as input.
      self.view_requirements = {
          SampleBatch.OBS: ViewRequirement(
              shift=0, space=self.obs_space
          ),
      }
  
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 1 to create a new ModelV2 object  with example: obj = ModelV2(obs_space, action_space, num_outputs, model_config, name, framework)