code: def copy_workdir(
      dst: str,
      custom_file_filter: Optional[
          Union[Callable[[str, List], List], CustomFileFilter]
      ] = None,
  ):
      """Copy the local working directory to the destination.
  
      Args:
          dst (str): destination path.
          custom_file_filter (Union[Callable[[str, List], List], CustomFileFilter): configuration that
              specifies how the local working directory should be packaged.
      """
  
      def _ignore_patterns(
          path: str, names: List
      ):  # pylint: disable=unused-argument
          ignored_names = set()
          if custom_file_filter.ignore_name_patterns is not None:
              for pattern in custom_file_filter.ignore_name_patterns:
                  ignored_names.update(fnmatch.filter(names, pattern))
          return ignored_names
  
      def _filter_non_python_files(path: str, names: List) -> List:
          """Ignore function for filtering out non python files."""
          to_ignore = []
          for name in names:
              full_path = os.path.join(path, name)
              if os.path.isfile(full_path):
                  if not name.endswith(".py"):
                      to_ignore.append(name)
              elif os.path.isdir(full_path):
                  if name == "__pycache__":
                      to_ignore.append(name)
              else:
                  to_ignore.append(name)
  
          return to_ignore
  
      _ignore = None
      _src = os.getcwd()
      if not custom_file_filter:
          _ignore = _filter_non_python_files
      elif callable(custom_file_filter):
          _ignore = custom_file_filter
      elif isinstance(custom_file_filter, CustomFileFilter):
          _ignore = _ignore_patterns
          _src = custom_file_filter.workdir
  
      shutil.copytree(
          _src,
          dst,
          ignore=_ignore,
      )
  
file_path: sagemaker-python-sdk/src/sagemaker/remote_function/custom_file_filter.py
imports: from __future__ import absolute_import
  import fnmatch
  import os
  import shutil
  from typing import List, Optional, Callable, Union
  from sagemaker.utils import resolve_value_from_config
  from sagemaker.config.config_schema import REMOTE_FUNCTION_PATH, CUSTOM_FILE_FILTER
label_desc: Use image node_id 2 for calling a global function with example usage: copy_workdir(dst, custom_file_filter) and returns: ignored_names, to_ignore