code: def replace_random(
      match: Match,
      size,
      *,
      generator=None,
      dtype=None,
      device=None,
      layout=None,
      pin_memory=None,
  ):
      if generator is not None:
          return
  
      def replacement(size):
          result = inductor_prims.random(
              size,
              inductor_prims.seed(device),
              mode,
              **default_kwargs(device),
          )
          if dtype is not None:
              result = result.to(dtype)
          return result
  
      mode = {
          aten.rand: "rand",
          aten.randn: "randn",
      }[match.output_node().target.overloadpacket]
      device = get_device(device)
      match.replace_by_example(replacement, [size])
  
file_path: pytorch/torch/_inductor/fx_passes/replace_random.py
imports: import collections
  import logging
  import torch
  from torch.fx.passes.shape_prop import _extract_tensor_metadata
  from ..None import config, inductor_prims
  from ..pattern_matcher import CallFunctionVarArgs, Match, PatternMatcherPass, register_graph_pattern
  from ..virtualized import V
label_desc: Use image node_id 5 for calling a global function with example usage: replace_random(match, size) and returns: result