code: def create_numba_random_fn(
      op: Op,
      node: Apply,
      scalar_fn: Callable[[str], str],
      global_env: Optional[dict[str, Any]] = None,
  ) -> Callable:
      """Create a vectorized function from a callable that generates the ``str`` function body.
  
      TODO: This could/should be generalized for other simple function
      construction cases that need unique-ified symbol names.
      """
      np_random_fn_name = (
          f"pytensor_random_{get_name_for_object(op.name)}"
      )
  
      if global_env:
          np_global_env = global_env.copy()
      else:
          np_global_env = {}
  
      np_global_env["np"] = np
      np_global_env["numba_vectorize"] = numba_basic.numba_vectorize
  
      unique_names = unique_name_generator(
          [
              np_random_fn_name,
          ]
          + list(np_global_env.keys())
          + [
              "rng",
              "size",
              "dtype",
          ],
          suffix_sep="_",
      )
  
      np_names = [
          unique_names(i, force_unique=True) for i in node.inputs[3:]
      ]
      np_input_names = ", ".join(np_names)
      np_random_fn_src = f"""
  @numba_vectorize
  def {np_random_fn_name}({np_input_names}):
  {scalar_fn(*np_names)}
      """
      np_random_fn = compile_function_src(
          np_random_fn_src,
          np_random_fn_name,
          {**globals(), **np_global_env},
      )
  
      return make_numba_random_fn(node, np_random_fn)
  
imports: from textwrap import dedent, indent
  from typing import Any, Callable, Optional
  import numba.np.unsafe.ndarray
  import numpy
  from numba import _helperlib, types
  from numba.core import cgutils
  from numba.extending import NativeValue, box, models, register_model, typeof_impl, unbox
  from numpy.random import RandomState
  import pytensor.tensor.random.basic
  from pytensor.graph.basic import Apply
  from pytensor.graph.op import Op
  from pytensor.link.numba.dispatch import basic
  from pytensor.link.numba.dispatch.basic import numba_funcify, numba_typify
  from pytensor.link.utils import compile_function_src, get_name_for_object, unique_name_generator
  from pytensor.tensor.basic import get_vector_length
  from pytensor.tensor.random.type import RandomStateType
label_desc: Use image node_id 7 for calling a global function with example usage: create_numba_random_fn(op, node, scalar_fn, global_env) and returns: make_numba_random_fn