code: def convert_shape(shape: Shape) -> Optional[StrongShape]:
      """Process a user-provided shape variable into None or a valid shape object."""
      if shape is None:
          return None
      elif isinstance(shape, int) or (
          isinstance(shape, TensorVariable) and shape.ndim == 0
      ):
          shape = (shape,)
      elif isinstance(shape, TensorVariable) and shape.ndim == 1:
          shape = tuple(shape)
      elif isinstance(shape, (list, tuple)):
          shape = tuple(shape)
      else:
          raise ValueError(
              f"The `shape` parameter must be a tuple, TensorVariable, int or list. Actual: {type(shape)}"
          )
  
      return shape
  
imports: import warnings
  from functools import singledispatch
  from typing import Any, Optional, Sequence, Tuple, Union, cast
  import numpy
  from pytensor import config
  from pytensor import tensor
  from pytensor.graph.basic import Variable
  from pytensor.graph.op import Op, compute_test_value
  from pytensor.raise_op import Assert
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.shape import SpecifyShape
  from pytensor.tensor.variable import TensorVariable
  from typing_extensions import TypeAlias
  from pymc.model import modelcontext
  from pymc.pytensorf import convert_observed_data
  from pymc.exceptions import ShapeError
  from pymc.pytensorf import PotentialShapeType
  from pymc.util import _add_future_warning_tag
label_desc: Use image node_id 5 for calling a global function with example usage: convert_shape(shape) and returns: shape, None