code: def _check_rank_valid(g, rank: int):
      """Check the rank: 0 <= rank < world_size."""
      if rank < 0:
          raise ValueError("rank '{}' is negative.".format(rank))
      if rank >= g.world_size:
          raise ValueError(
              "rank '{}' must be less than world size '{}'".format(
                  rank, g.world_size
              )
          )
  
imports: import logging
  import os
  from typing import List
  import numpy
  import ray
  from ray.util.collective import types
label_desc: Use image node_id 29 for calling a global function with example usage: _check_rank_valid(g, rank) without return types