code: def as_tensor_variable(
      x: TensorLike,
      name: Optional[str] = None,
      ndim: Optional[int] = None,
      **kwargs,
  ) -> "TensorVariable":
      """Convert `x` into an equivalent `TensorVariable`.
  
      This function can be used to turn ndarrays, numbers, `ScalarType` instances,
      `Apply` instances and `TensorVariable` instances into valid input list
      elements.
  
      See `pytensor.as_symbolic` for a more general conversion function.
  
      Parameters
      ----------
      x
          The object to be converted into a `Variable` type. A
          `numpy.ndarray` argument will not be copied, but a list of numbers
          will be copied to make an `numpy.ndarray`.
      name
          If a new `Variable` instance is created, it will be named with this
          string.
      ndim
          Return a `Variable` with this many dimensions.
      dtype
          The dtype to use for the resulting `Variable`.  If `x` is already
          a `Variable` type, then the dtype will not be changed.
  
      Raises
      ------
      TypeError
          If `x` cannot be converted to a `TensorVariable`.
  
      """
      return _as_tensor_variable(x, name, ndim, **kwargs)
  
imports: from collections.abc import Sequence
  from functools import singledispatch
  from typing import TYPE_CHECKING, Any, Callable, NoReturn, Optional, Union
  from pytensor.graph.basic import Constant, Variable
  from pytensor.graph.op import Op
  import pytensor.tensor.exceptions
  from pytensor.gradient import grad, hessian, jacobian
  from pytensor.tensor import sharedvar
  from pytensor.tensor import blas, blas_c, blas_scipy, xlogx
  import pytensor.tensor.rewriting
  from pytensor.tensor import linalg
  from pytensor.tensor import special
  from pytensor.tensor import nlinalg
  from pytensor.tensor import slinalg
  from pytensor.tensor.basic import *
  from pytensor.tensor.blas import batched_dot, batched_tensordot
  from pytensor.tensor.extra_ops import *
  from pytensor.tensor.shape import reshape, shape, shape_padaxis, shape_padleft, shape_padright, specify_broadcastable, specify_shape
  from pytensor.tensor.io import *
  from pytensor.tensor.math import *
  from pytensor.tensor.sort import argsort, argtopk, sort, topk, topk_and_argtopk
  from pytensor.tensor.subtensor import *
  from pytensor.tensor.type import *
  from pytensor.tensor.type_other import *
  from pytensor.tensor.variable import TensorConstant, TensorVariable
  from pytensor.tensor.functional import vectorize
  from numpy import e, euler_gamma, inf, infty, nan, newaxis, pi
label_desc: Use image node_id 1 for calling a global function with example usage: as_tensor_variable(x, name, ndim) and returns: _as_tensor_variable