code: def alias_root(v):
      """
      Return the variable to which v is aliased by view_maps and destroy_maps.
  
      """
      if v.owner is None:
          return v
      vmap = v.owner.op.view_map
      dmap = v.owner.op.destroy_map
      outpos = v.owner.outputs.index(v)
      v_views = vmap.get(outpos, []) + dmap.get(outpos, [])
      if len(v_views) > 1:
          raise NotImplementedError(
              f"{v} is a view/destroyed version of more then one inputs. "
              "Currently, we only support the case where an output is a view or "
              "a destroyed version of one input."
          )
      elif v_views:
          return alias_root(v.owner.inputs[v_views[0]])
      else:
          return v
  
imports: import copy
  import copyreg
  import logging
  import time
  import warnings
  from itertools import chain
  from typing import TYPE_CHECKING, Optional
  import numpy
  import pytensor
  import pytensor.compile.profiling
  from pytensor.compile.io import In, SymbolicInput, SymbolicOutput
  from pytensor.compile.ops import deep_copy_op, view_op
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Constant, Variable, ancestors, clone_get_equiv, graph_inputs
  from pytensor.graph.destroyhandler import DestroyHandler
  from pytensor.graph.features import AlreadyThere, Feature, PreserveVariableAttributes
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.op import HasInnerGraph
  from pytensor.graph.utils import InconsistencyError, get_variable_trace_string
  from pytensor.link.basic import Container
  from pytensor.link.utils import raise_with_op
label_desc: Use image node_id 1 for calling a global function with example usage: alias_root(v) and returns: v, alias_root, v