code: def threefry_split(gen):
      """Split a single generator state into two new ones
  
      Notes
      -----
      The new generator is created by appending a one (for the right output) or a zero (for the left
      output) to the end of the path portion of the generator If there is no longer and room in the
      path, then we create a new key portion of the generator by applying Threefry to the old state,
      path, and counter. i.e. :code:`new_key = threefry(old_key, [old_path, old_counter])`. This
      resets the path portion of the new generator.
  
      Parameters
      ----------
      gen : Tensor[10, uint64]
          Generator state. Can be create with :py:func:`tvm.relay.random.threefry_key`. This should
          not be reused in another function, otherwise random numbers will be repeated.
  
      Returns
      -------
      out_gen_left : Tensor[10, uint64]
          New generator state that is distinct from `out_gen_right`.
  
      out_gen_right : Tensor[10, uint64]
          New generator state that is distinct from `out_gen_left`.
      """
  
      def gen_ir(gen_ptr, out_left_ptr, out_right_ptr):
          irb = ir_builder.create()
          gen = irb.buffer_ptr(gen_ptr)
          out_left = irb.buffer_ptr(out_left_ptr)
          out_right = irb.buffer_ptr(out_right_ptr)
  
          with irb.if_scope(gen[8] == 0 and gen[9] == 0):
              # Generate new key because we have run out of room to extend the path
              _threefry(irb, gen, 0, gen, 4, out_left, 0, 1)
              out_left[4] = tir.const(0, dtype=gen.dtype)
              out_left[5] = tir.const(0, dtype=gen.dtype)
              out_left[6] = tir.const(
                  0, dtype=gen.dtype
              )  # counter gets zeroed
              out_left[7] = tir.const(
                  0, dtype=gen.dtype
              )  # counter gets zeroed
              out_left[8] = tir.const(
                  1 << 62, dtype=gen.dtype
              )  # one in the second from the leftmost position
              out_left[9] = tir.const(0, dtype=gen.dtype)
  
              out_right[0] = out_left[0]
              out_right[1] = out_left[1]
              out_right[2] = out_left[2]
              out_right[3] = out_left[3]
              out_right[4] = tir.const(
                  1 << 63, dtype=gen.dtype
              )  # one in the leftmost position
              out_right[5] = tir.const(0, dtype=gen.dtype)
              out_right[6] = tir.const(0, dtype=gen.dtype)
              out_right[7] = tir.const(0, dtype=gen.dtype)
              out_right[8] = tir.const(
                  1 << 62, dtype=gen.dtype
              )  # one in the second from the leftmost position
              out_right[9] = tir.const(0, dtype=gen.dtype)
          with irb.else_scope():
              out_left[0] = gen[0]
              out_left[1] = gen[1]
              out_left[2] = gen[2]
              out_left[3] = gen[3]
              out_left[4] = gen[
                  4
              ]  # adding a zero here, but its already zero padded
              out_left[5] = gen[5]
              out_left[6] = gen[6]
              out_left[7] = gen[7]
              # move path position over one bit
              _shift_right(
                  irb, gen[8], gen[9], out_left, 8, out_left, 9
              )
  
              out_right[0] = gen[0]
              out_right[1] = gen[1]
              out_right[2] = gen[2]
              out_right[3] = gen[3]
              out_right[4] = gen[4] | gen[8]  # add a one to the path
              out_right[5] = gen[5] | gen[9]
              out_right[6] = gen[6]
              out_right[7] = gen[7]
              _shift_right(
                  irb, gen[8], gen[9], out_right, 8, out_right, 9
              )
  
          return irb.get()
  
      out_left = tvm.tir.decl_buffer(
          (10,), name="out_left", dtype="uint64"
      )
      out_right = tvm.tir.decl_buffer(
          (10,), name="out_right", dtype="uint64"
      )
      return tvm.te.extern(
          [out_left.shape, out_right.shape],
          [gen],
          lambda ins, outs: gen_ir(ins[0], outs[0], outs[1]),
          out_buffers=[out_left, out_right],
          name="threefry_split",
          tag="threefry_split",
      )
  
file_path: tvm/python/tvm/topi/random/kernel.py
imports: import math
  import numpy
  import tvm
  import tvm.topi
  from ...None import tir
  from ...tir import ir_builder
label_desc: Use image node_id 4 for calling a global function with example usage: threefry_split(gen) and returns: tvm, irb