code: def optional_args(decorator):
      """
      allows a decorator to take optional positional and keyword arguments.
      Assumes that taking a single, callable, positional argument means that
      it is decorating a function, i.e. something like this::
  
          @my_decorator
          def function(): pass
  
      Calls decorator with decorator(f, *args, **kwargs)
      """
  
      @wraps(decorator)
      def wrapper(*args, **kwargs):
          def dec(f):
              return decorator(f, *args, **kwargs)
  
          is_decorating = (
              not kwargs and len(args) == 1 and callable(args[0])
          )
          if is_decorating:
              f = args[0]
              args = ()
              return dec(f)
          else:
              return dec
  
      return wrapper
  
imports: from __future__ import annotations
  import bz2
  from functools import wraps
  import gzip
  import io
  import socket
  import tarfile
  from typing import TYPE_CHECKING, Any, Callable
  import zipfile
  from pandas._typing import FilePath, ReadPickleBuffer
  from pandas.compat import get_lzma_file
  from pandas.compat._optional import import_optional_dependency
  import pandas
  from pandas._testing._random import rands
  from pandas._testing.contexts import ensure_clean
  from pandas.io.common import urlopen
label_desc: Use image node_id 2 for calling a global function with example usage: optional_args(decorator) and returns: wrapper, decorator, dec, dec