code: def finalize_randomness(x):
      import hail.ir.ir as ir
  
      if isinstance(x, ir.IR):
          x = ir.Let("__rng_state", ir.RNGStateLiteral(), x)
      elif isinstance(x, ir.TableIR):
          x = x.handle_randomness(None)
      elif isinstance(x, ir.MatrixIR):
          x = x.handle_randomness(None, None)
      return x
  
file_path: hail/hail/python/hail/ir/utils.py
imports: from typing import Optional, List, Any, Tuple
  import hail
  from hail.utils.java import Env
  from hail.expr.types import tint32, tint64
label_desc: Use image node_id 1 for calling a global function with example usage: finalize_randomness(x) and returns: x