code: def _generate_state(base_seed, worker_id):
      INIT_A = 0x43B0D7E5
      MULT_A = 0x931E8875
      INIT_B = 0x8B51F9DD
      MULT_B = 0x58F38DED
      MIX_MULT_L = 0xCA01F9DD
      MIX_MULT_R = 0x4973F715
      XSHIFT = 4 * 8 // 2
      MASK32 = 0xFFFFFFFF
  
      entropy = [worker_id, base_seed & MASK32, base_seed >> 32, 0]
      pool = [0] * 4
  
      hash_const_A = INIT_A
  
      def hash(value):
          nonlocal hash_const_A
          value = (value ^ hash_const_A) & MASK32
          hash_const_A = (hash_const_A * MULT_A) & MASK32
          value = (value * hash_const_A) & MASK32
          value = (value ^ (value >> XSHIFT)) & MASK32
          return value
  
      def mix(x, y):
          result_x = (MIX_MULT_L * x) & MASK32
          result_y = (MIX_MULT_R * y) & MASK32
          result = (result_x - result_y) & MASK32
          result = (result ^ (result >> XSHIFT)) & MASK32
          return result
  
      # Add in the entropy to the pool.
      for i in range(len(pool)):
          pool[i] = hash(entropy[i])
  
      # Mix all bits together so late bits can affect earlier bits.
      for i_src in range(len(pool)):
          for i_dst in range(len(pool)):
              if i_src != i_dst:
                  pool[i_dst] = mix(pool[i_dst], hash(pool[i_src]))
  
      hash_const_B = INIT_B
      state = []
      for i_dst in range(4):
          data_val = pool[i_dst]
          data_val = (data_val ^ hash_const_B) & MASK32
          hash_const_B = (hash_const_B * MULT_B) & MASK32
          data_val = (data_val * hash_const_B) & MASK32
          data_val = (data_val ^ (data_val >> XSHIFT)) & MASK32
          state.append(data_val)
      return state
  
file_path: pytorch/torch/utils/data/_utils/worker.py
imports: import torch
  import random
  import os
  import queue
  from dataclasses import dataclass
  from torch._utils import ExceptionWrapper
  from typing import Optional, Union, TYPE_CHECKING
  from .None import signal_handling, MP_STATUS_CHECK_INTERVAL, IS_WINDOWS, HAS_NUMPY
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_state(base_seed, worker_id) and returns: state, value, result