class_docstr: Torch version of ModelV2.
  
  Note that this class by itself is not a valid model unless you
  inherit from nn.Module and implement forward() in a subclass.
class_docstr_tok: ["Torch","version","of","ModelV2",".","Note","that","this","class","by","itself","is","not","a","valid","model","unless","you","inherit","from","nn.Module","and","implement","forward","(",")","in","a","subclass","."]
code: def variables(
      self, as_dict: bool = False
  ) -> Union[List[TensorType], Dict[str, TensorType]]:
      p = list(self.parameters())
      if as_dict:
          return {
              k: p[i] for i, k in enumerate(self.state_dict().keys())
          }
      return p
  
file_path: ray/python/ray/rllib/models/torch/torch_modelv2.py
imports: import gymnasium
  from typing import Dict, List, Union
  from ray.rllib.models.modelv2 import ModelV2
  from ray.rllib.utils.annotations import override, PublicAPI
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.typing import ModelConfigDict, TensorType
label_desc: Use image node_id 2 for calling the TorchModelV2 obj's underlying member method code with example usage: obj.variables(as_dict) and returns: p, unknown