code: def main(
      trials: int,
      batch_size: int,
      payload_type: PayloadType,
      serializer: SerializerType,
      profile_events: bool,
  ):
      if serializer == SerializerType.RAY:
  
          def _serialize(obj):
              so = sc.serialize(obj)
              bs = so.to_bytes()
              return bs
  
      elif serializer == SerializerType.CLOUDPICKLE:
  
          def _serialize(obj):
              bs = cloudpickle_fast.dumps(obj)
              return bs
  
      elif serializer == SerializerType.PICKLE:
  
          def _serialize(obj):
              bs = pickle.dumps(obj)
              return bs
  
      elif serializer == SerializerType.MSGPACK:
  
          def _dumps(obj):
              bs = msgpack.dumps(obj.__dict__)
              # print(f"Bytes ({len(bs)}): ", bs)
              return bs
  
          def _loads(bs):
              dict = msgpack.loads(bs)
              return PayloadPydantic(**dict)
  
          sc._register_cloudpickle_serializer(
              PayloadPydantic, _dumps, _loads
          )
  
          def _serialize(obj):
              so = sc.serialize(obj)
              bs = so.to_bytes()
              return bs
  
      else:
          raise NotImplementedError(serializer)
  
      if payload_type == PayloadType.PYDANTIC:
          model = _create_model(PayloadPydantic)
      elif payload_type == PayloadType.DATACLASS:
          model = _create_model(PayloadDataclass)
      else:
          raise NotImplementedError(f"Not supported ({payload_type})")
  
      payload = [model.copy(deep=True) for _ in range(batch_size)]
  
      routine = run_serializer_benchmark(payload, _serialize, trials)
  
      if profile_events:
          routine = collect_profile_events(routine)
  
      asyncio.run(routine)
  
file_path: ray/python/ray/serve/_private/benchmarks/serialization/serialization_benchmark.py
imports: import asyncio
  import enum
  import pickle
  import time
  from typing import Any, Callable
  import click
  import msgpack
  from ray._private.serialization import SerializationContext
  from ray.cloudpickle import cloudpickle_fast
  from ray.serve._private.benchmarks.common import collect_profile_events, run_latency_benchmark
  from ray.serve._private.benchmarks.serialization.common import PayloadDataclass, PayloadPydantic
label_desc: Use image node_id 3 for calling a global function with example usage: main(trials, batch_size, payload_type, serializer, profile_events) and returns: bs, bs, bs, bs, PayloadPydantic, bs