code: def test_invalid_arguments():
      import re
  
      def f():
          return 1
  
      class A:
          x = 1
  
      template1 = (
          "The type of keyword '{}' "
          + f"must be {(int, type(None))}, but received type {float}"
      )
  
      # Type check
      for keyword in ("max_retries", "max_calls"):
          with pytest.raises(
              TypeError, match=re.escape(template1.format(keyword))
          ):
              ray.remote(**{keyword: random.random()})(f)
      num_returns_template = (
          "The type of keyword 'num_returns' "
          + f"must be {(int, str, type(None))}, but received type {float}"
      )
      with pytest.raises(
          TypeError, match=re.escape(num_returns_template)
      ):
          ray.remote(**{"num_returns": random.random()})(f)
  
      for keyword in ("max_restarts", "max_task_retries"):
          with pytest.raises(
              TypeError, match=re.escape(template1.format(keyword))
          ):
              ray.remote(**{keyword: random.random()})(A)
  
      # Value check for non-negative finite values
      for v in (random.randint(-100, -2), -1):
          keyword = "max_calls"
          with pytest.raises(
              ValueError,
              match=f"The keyword '{keyword}' only accepts None, "
              f"0 or a positive integer",
          ):
              ray.remote(**{keyword: v})(f)
  
          keyword = "num_returns"
          with pytest.raises(
              ValueError,
              match=f"The keyword '{keyword}' only accepts None, "
              "a non-negative integer, "
              "'streaming' \(for generators\), or 'dynamic'",
          ):
              ray.remote(**{keyword: v})(f)
  
      # Value check for non-negative and infinite values
      template2 = (
          "The keyword '{}' only accepts None, 0, -1 or a positive integer, "
          "where -1 represents infinity."
      )
  
      with pytest.raises(
          ValueError, match=template2.format("max_retries")
      ):
          ray.remote(max_retries=random.randint(-100, -2))(f)
  
      for keyword in ("max_restarts", "max_task_retries"):
          with pytest.raises(
              ValueError, match=template2.format(keyword)
          ):
              ray.remote(**{keyword: random.randint(-100, -2)})(A)
  
      metadata_type_err = (
          "The type of keyword '_metadata' "
          + f"must be {(dict, type(None))}, but received type {float}"
      )
      with pytest.raises(TypeError, match=re.escape(metadata_type_err)):
          ray.remote(_metadata=3.14)(A)
  
      ray.remote(_metadata={"data": 1})(f)
      ray.remote(_metadata={"data": 1})(A)
  
      # Check invalid resource quantity
      with pytest.raises(
          ValueError,
          match=(
              "The precision of the fractional quantity of resource num_gpus"
              " cannot go beyond 0.0001"
          ),
      ):
          ray.remote(num_gpus=0.0000001)(f)
  
      with pytest.raises(
          ValueError,
          match=(
              "The precision of the fractional quantity of resource custom_resource"
              " cannot go beyond 0.0001"
          ),
      ):
          ray.remote(resources={"custom_resource": 0.0000001})(f)
  
imports: import logging
  import os
  import pickle
  import random
  import sys
  import time
  import pytest
  import ray
  import ray.cluster_utils
  from ray._private.test_utils import SignalActor, client_test_enabled, get_error_message, run_string_as_driver
label_desc: Use image node_id 10 for calling a global function with example usage: test_invalid_arguments() and returns: int