code: def local_fill_to_alloc(fgraph, node):
      r"""Remove `fill`\s or replace them with `Alloc`\s.
  
      `Alloc`\s are preferable because they replace explicit tensor dependencies
      with their dependencies on those tensors' shapes, and sometimes those
      shapes can be computed without needing to compute the tensors themselves.
  
      Like `local_fill_sink` this rewrites assumes non-broadcastable shapes are equivalent,
      which could mask shape errors.
      """
      shape_ref, values_ref = node.inputs
      out_type = node.outputs[0].type
  
      if values_ref.type.broadcastable == out_type.broadcastable:
          # The assumption here is that `values_ref` already has the same shape
          # as `shape_ref`, so a `fill`/`Alloc` is unnecessary.
          return [values_ref]
  
      if shape_ref.type.broadcastable == out_type.broadcastable:
          # In this case, we assume that some broadcasting is needed (otherwise
          # the condition above would've been true), so we replace the `fill`
          # with an `Alloc`.
          o = alloc_like(
              values_ref, shape_ref, fgraph, dtype=values_ref.dtype
          )
          copy_stack_trace(node.outputs[0], o)
          return [o]
  
      # The case that is not covered is when `shape_ref` is broadcasted by `values_ref`
      # TODO: Return broadcast_to(values_ref, broadcast_shapes(values_ref.shape, shape_ref.shape))
  
      return
  
imports: import logging
  from typing import Union
  import numpy
  import pytensor.scalar.basic
  from pytensor import compile
  from pytensor.compile.ops import ViewOp
  from pytensor.graph import FunctionGraph
  from pytensor.graph.basic import Constant, Variable
  from pytensor.graph.rewriting.basic import NodeRewriter, RemovalNodeRewriter, Rewriter, copy_stack_trace, in2out, node_rewriter
  from pytensor.graph.rewriting.db import RewriteDatabase
  from pytensor.raise_op import Assert, CheckAndRaise, assert_op
  from pytensor.tensor.basic import Alloc, AllocEmpty, Join, MakeVector, ScalarFromTensor, Split, TensorFromScalar, alloc, as_tensor_variable, cast, extract_constant, fill, get_underlying_scalar_constant_value, join, ones_like, register_infer_shape, switch, tensor_copy, zeros, zeros_like
  from pytensor.tensor.elemwise import DimShuffle, Elemwise
  from pytensor.tensor.exceptions import NotScalarConstantError
  from pytensor.tensor.extra_ops import broadcast_arrays
  from pytensor.tensor.math import Sum, add, eq
  from pytensor.tensor.shape import Shape_i, shape_padleft
  from pytensor.tensor.sort import TopKOp
  from pytensor.tensor.type import DenseTensorType, TensorType
  from pytensor.tensor.variable import TensorConstant, TensorVariable
  from pytensor.utils import NoDuplicateOptWarningFilter
label_desc: Use image node_id 13 for calling a global function with example usage: local_fill_to_alloc(fgraph, node) and returns: list, list