code: def get_files(d, pattern, sort=True):
      """Return a list of files in a given directory.
  
      Args:
        d (str): The path to the directory.
        pattern (str): The wildcard to filter files with.
        sort (bool): Whether to sort the returned list. Assumes filenames contain a number value to sort by (tmp-001).
      """
      files = glob(os.path.join(d, pattern))
      files = [f for f in files if os.path.isfile(f)]
      if sort:
  
          def filter_numeric(s):
              return re.sub("[^0-9]", "", s)
  
          files.sort(
              key=lambda x: int(
                  filter_numeric(os.path.basename(x).split(".")[0])
              )
          )
      return files
  
imports: import errno
  import logging
  import os
  import re
  import shutil
  import signal
  import tempfile
  import uuid
  from abc import ABC, abstractmethod
  from glob import glob
  from typing import Any, Dict, Mapping, Optional, Tuple, TYPE_CHECKING
  import torch
  from torch.optim import Optimizer
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.modules.lr_scheduler import LRScheduler
label_desc: Use image node_id 2 for calling a global function with example usage: get_files(d, pattern, sort) and returns: files, re