class_docstr: The base class for distribution over a random variable.
  
  Examples:
  
  .. testcode::
  
      import torch
      from ray.rllib.core.models.configs import MLPHeadConfig
      from ray.rllib.models.torch.torch_distributions import TorchCategorical
  
      model = MLPHeadConfig(input_dims=[1]).build(framework="torch")
  
      # Create an action distribution from model logits
      action_logits = model(torch.Tensor([[1]]))
      action_dist = TorchCategorical.from_logits(action_logits)
      action = action_dist.sample()
  
      # Create another distribution from a dummy Tensor
      action_dist2 = TorchCategorical.from_logits(torch.Tensor([0]))
  
      # Compute some common metrics
      logp = action_dist.logp(action)
      kl = action_dist.kl(action_dist2)
      entropy = action_dist.entropy()
class_docstr_tok: ["The","base","class","for","distribution","over","a","random","variable",".","Examples",":","..","testcode",":",":","import","torch","from","ray.rllib.core.models.configs","import","MLPHeadConfig","from","ray.rllib.models.torch.torch_distributions","import","TorchCategorical","model","=","MLPHeadConfig","(","input_dims=","[","1","]",")",".build","(","framework=","''","torch","''",")","#","Create","an","action","distribution","from","model","logits","action_logits","=","model","(","torch.Tensor","(","[","[","1","]","]",")",")","action_dist","=","TorchCategorical.from_logits","(","action_logits",")","action","=","action_dist.sample","(",")","#","Create","another","distribution","from","a","dummy","Tensor","action_dist2","=","TorchCategorical.from_logits","(","torch.Tensor","(","[","0","]",")",")","#","Compute","some","common","metrics","logp","=","action_dist.logp","(","action",")","kl","=","action_dist.kl","(","action_dist2",")","entropy","=","action_dist.entropy","(",")"]
docstr: Returns the required length of an input parameter tensor.
  
  Args:
      space: The space this distribution will be used for,
          whose shape attributes will be used to determine the required shape of
          the input parameter tensor.
      **kwargs: Forward compatibility placeholder.
  
  Returns:
      size of the required input vector (minus leading batch dimension).
docstr_tok: ["Returns","the","required","length","of","an","input","parameter","tensor",".","Args",":","space",":","The","space","this","distribution","will","be","used","for",",","whose","shape","attributes","will","be","used","to","determine","the","required","shape","of","the","input","parameter","tensor",".","*","*","kwargs",":","Forward","compatibility","placeholder",".","Returns",":","size","of","the","required","input","vector","(","minus","leading","batch","dimension",")","."]
code: def required_input_dim(space: gym.Space, **kwargs) -> int:
      """Returns the required length of an input parameter tensor.
  
      Args:
          space: The space this distribution will be used for,
              whose shape attributes will be used to determine the required shape of
              the input parameter tensor.
          **kwargs: Forward compatibility placeholder.
  
      Returns:
          size of the required input vector (minus leading batch dimension).
      """
  
file_path: ray/rllib/models/distributions.py
imports: from typing import Tuple
  import gymnasium
  import abc
  from ray.rllib.utils.annotations import ExperimentalAPI
  from ray.rllib.utils.typing import TensorType, Union
  from ray.rllib.utils.annotations import override
label_desc: Use image node_id 6 for calling the Distribution obj's underlying member method code with example usage: obj.required_input_dim(space) without return types