code: def payload_paramss_to_batch_params(
      paramss: t.Sequence[Params[Payload]],
      batch_dim: int,
      # TODO: support mapping from arg to batch dimension
  ) -> tuple[Params[t.Any], list[int]]:
      from ..runner.container import AutoContainer
  
      _converted_params = Params.agg(
          paramss,
          agg_func=lambda i: AutoContainer.from_batch_payloads(
              i,
              batch_dim=batch_dim,
          ),
      ).iter()
      batched_params = next(_converted_params)
      indice_params: Params[list[int]] = next(_converted_params)
  
      # considering skip this check if the CPU overhead of each inference is too high
      if not indice_params.all_equal():
          raise InvalidArgument(
              f"argument lengths for parameters do not matchs: {tuple(indice_params.items())}"
          )
      return batched_params, indice_params.sample
  
imports: from __future__ import annotations
  import itertools
  import logging
  import typing
  from typing import TYPE_CHECKING
  import anyio
  from bentoml.exceptions import InvalidArgument
label_desc: Use image node_id 2 for calling a global function with example usage: payload_paramss_to_batch_params(paramss, batch_dim) and returns: batched_params,  indice_params