code: def get_clients_at_depth(
      fgraph: FunctionGraph, node: Apply, depth: int
  ) -> Generator[Apply, None, None]:
      """Yields node clients at given depth."""
      for var in node.outputs:
          if depth > 0:
              for out_node, _ in fgraph.clients[var]:
                  if out_node == "output":
                      continue
                  yield from get_clients_at_depth(
                      fgraph, cast(Apply, out_node), depth - 1
                  )
          else:
              assert var.owner is not None
              yield var.owner
  
file_path: pytensor/pytensor/graph/rewriting/utils.py
imports: import copy
  from collections.abc import Generator, Sequence
  from typing import TYPE_CHECKING, Optional, Union, cast
  import pytensor
  from pytensor.graph.basic import Apply, Variable, equal_computations, graph_inputs, vars_between
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.rewriting.db import RewriteDatabaseQuery
label_desc: Use image node_id 4 for calling a global function with example usage: get_clients_at_depth(fgraph, node, depth) without return types