class_docstr: Centralised, batched inference server.
class_docstr_tok: ["Centralised",",","batched","inference","server","."]
docstr: Builds a batched handler for a given callable handler and its name.
docstr_tok: ["Builds","a","batched","handler","for","a","given","callable","handler","and","its","name","."]
code: def _build_handler(
      self, handler: Callable[..., Any]
  ) -> Callable[..., Any]:
      """Builds a batched handler for a given callable handler and its name."""
  
      def dereference_params_and_call_handler(*args, **kwargs):
          with self._mutex:
              # Dereference args corresponding to params, leaving others unchanged.
              args_with_dereferenced_params = [
                  self._dereference_params(arg) for arg in args
              ]
              kwargs_with_dereferenced_params = {
                  key: self._dereference_params(value)
                  for key, value in kwargs.items()
              }
              self._call_cnt += 1
  
              # Maybe update params, depending on client configuration.
              if self._variable_client is not None:
                  self._variable_client.update()
  
          return handler(
              *args_with_dereferenced_params,
              **kwargs_with_dereferenced_params,
          )
  
      return lp.batched_handler(
          batch_size=self._config.batch_size,
          timeout=self._config.timeout,
          pad_batch=True,
          max_parallelism=2 * len(self._devices),
      )(dereference_params_and_call_handler)
  
file_path: acme/acme/jax/inference_server.py
imports: import dataclasses
  import datetime
  import threading
  from typing import Any, Callable, Generic, Optional, Sequence, TypeVar
  import acme
  from acme.jax import variable_utils
  import jax
  import launchpad
label_desc: Use image node_id 4 for calling the InferenceServer obj's underlying member method code with example usage: obj._build_handler(handler) and returns: lp, handler