code: def broadcast_properties(f: "Callable[_P, _T]") -> "Callable[_P, _T]":
      """Method decorator to fetch updated trial properties from rank 0 after ``f`` is run.
  
      This decorator ensures trial properties (params, distributions, etc.) on all distributed
      processes are up-to-date with the wrapped trial stored on rank 0.
      It should be applied to all :class:`~optuna.integration.TorchDistributedTrial`
      methods that update property values.
      """
  
      @functools.wraps(f)
      def wrapped(*args: "_P.args", **kwargs: "_P.kwargs") -> "_T":
          # TODO(nlgranger): Remove type ignore after mypy includes
          # https://github.com/python/mypy/pull/12668
          self: TorchDistributedTrial = args[0]  # type: ignore[assignment]
  
          def fetch_properties() -> Sequence:
              assert self._delegate is not None
              return (
                  self._delegate.number,
                  self._delegate.params,
                  self._delegate.distributions,
                  self._delegate.user_attrs,
                  self._delegate.system_attrs,
                  self._delegate.datetime_start,
              )
  
          try:
              return f(*args, **kwargs)
          finally:
              (
                  self._number,
                  self._params,
                  self._distributions,
                  self._user_attrs,
                  self._system_attrs,
                  self._datetime_start,
              ) = self._call_and_communicate_obj(fetch_properties)
  
      return wrapped
  
imports: from datetime import datetime
  import functools
  import pickle
  from typing import Any
  from typing import Callable
  from typing import Dict
  from typing import Optional
  from typing import overload
  from typing import Sequence
  from typing import TYPE_CHECKING
  from typing import TypeVar
  import optuna
  from optuna._deprecated import deprecated_func
  from optuna._experimental import experimental_class
  from optuna._imports import try_import
  from optuna.distributions import BaseDistribution
  from optuna.distributions import CategoricalChoiceType
label_desc: Use image node_id 1 for calling a global function with example usage: broadcast_properties(f) and returns: wrapped, self,  self,  self,  self,  self,  self, f