code: def run_tensorflow_script(
      script: Union[bytes, str, BinaryIO, TextIO],
      n_workers: int,
      n_ps: int = 0,
      data: Dict[str, TileableType] = None,
      gpu: Optional[bool] = None,
      command_argv: List[str] = None,
      retry_when_fail: bool = False,
      session: SessionType = None,
      run_kwargs: Dict[str, Any] = None,
  ):
      """
      Run TensorFlow script in Mars cluster.
  
      Parameters
      ----------
      script: str or file-like object
          Script to run
      n_workers : int
          Number of TensorFlow workers.
      n_ps : int
          Number of TensorFlow PS workers.
      data : dict
          Variable name to data.
      gpu : bool
          Run PyTorch script on GPU
      command_argv : list
          Extra command args for script
      retry_when_fail : bool
          If True, retry when function failed.
      session
          Mars session, if not provided, will use default one.
      run_kwargs : dict
          Extra kwargs for `session.run`.
  
      Returns
      -------
      status
          return {'status': 'ok'} if succeeded, or error raised
      """
      if int(n_workers) <= 0:
          raise ValueError("n_workers should be at least 1")
      if int(n_ps) < 0:
          raise ValueError("n_ps should be at least 0")
      if hasattr(script, "read"):
          code = script.read()
      else:
          with open(os.path.abspath(script), "rb") as f:
              code = f.read()
  
      inputs = _extract_inputs(data)
      op = RunTensorFlow(
          data=data,
          code=to_binary(code),
          n_workers=int(n_workers),
          n_ps=int(n_ps),
          retry_when_fail=retry_when_fail,
          gpu=gpu,
          command_args=command_argv,
      )
      return op(inputs).execute(session=session, **(run_kwargs or {}))
  
imports: import os
  import json
  from typing import Any, BinaryIO, Dict, List, Optional, TextIO, Union
  import numpy
  from ....None import opcodes
  from ....core import recursive_tile
  from ....core.context import get_context
  from ....remote.run_script import RunScript, _extract_inputs
  from ....serialization.serializables import BytesField, Int32Field, DictField, StringField
  from ....typing import SessionType, TileableType
  from ....utils import to_binary
  from ...utils import collect_ports
  from ..utils import pick_workers
label_desc: Use image node_id 1 for calling a global function with example usage: run_tensorflow_script(script, n_workers, n_ps, data, gpu, command_argv, retry_when_fail, session, run_kwargs) and returns: op