code: def partialfactory(cls, lookup_string, *base_args, **base_kwargs):
      """Builds a factory with partial application of given args and keywords.
  
      Equivalent to functools.partial, but with a warning to prevent potential
      future headaches when overwriting keyword arguments. base_args are prepended
      to the positional arguments given during initialization and base_kwargs are
      updated with the kwargs given later.
  
      Args:
        cls: The base class.
        lookup_string: String for logging purposes.
        *base_args: Positional arguments to be preprended to all factory calls.
        **base_kwargs: Keyword arguments to be applied to all factory calls. These
          may be overwritten by kwargs in factory calls.
  
      Returns:
        A factory function creating objects of class `cls`.
  
      Author: Joan Puigcerver (jpuigcerver@),
        modifications by Paul Rubenstein (paulrubenstein@)
      """
  
      def _factory_fn(*args, **kwargs):
          """A factory function that creates objects of the registered class."""
          args = base_args + args
          for k, v in base_kwargs.items():
              if k in kwargs:
                  # Warning to prevent future headaches.
                  logging.warning(
                      "The default kwarg %r=%r, used in the lookup string %r, "
                      "is overridden by the call to the resulting factory. "
                      "Notice that this may lead to some unexpected behavior.",
                      k,
                      v,
                      lookup_string,
                  )
              else:
                  kwargs[k] = v
  
          return cls(*args, **kwargs)
  
      return _factory_fn
  
file_path: scenic/scenic/dataset_lib/big_transfer/registry.py
imports: import ast
  import functools
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: partialfactory(cls, lookup_string) and returns: _factory_fn, cls