code: def _set_operation_random_seed(
      operation: Union[
          DataOperationImplementation, ModelImplementation
      ],
      seed: Optional[int],
  ):
      old_random_state = None
      if hasattr(operation, "random_state"):
          old_random_state = getattr(operation, "random_state")
          setattr(operation, "random_state", seed)
  
      elif hasattr(operation, "seed"):
          old_random_state = getattr(operation, "seed")
          setattr(operation, "seed", seed)
  
      return old_random_state
  
file_path: FEDOT/fedot/utilities/random.py
imports: from typing import Optional, Union
  from fedot.core.operations.evaluation.operation_implementations.implementation_interfaces import DataOperationImplementation, ModelImplementation
  from fedot.core.utils import RandomStateHandler
label_desc: Use image node_id 1 for calling a global function with example usage: _set_operation_random_seed(operation, seed) and returns: old_random_state