code: def get_all_datasets(
      all_logdirs, legend=None, select=None, exclude=None
  ):
      """
      For every entry in all_logdirs,
          1) check if the entry is a real directory and if it is,
             pull data from it;
  
          2) if not, check to see if the entry is a prefix for a
             real directory, and pull data from that.
      """
      logdirs = []
      for logdir in all_logdirs:
          if osp.isdir(logdir) and logdir[-1] == os.sep:
              logdirs += [logdir]
          else:
              basedir = osp.dirname(logdir)
              fulldir = lambda x: osp.join(basedir, x)
              prefix = logdir.split(os.sep)[-1]
              listdir = os.listdir(basedir)
              logdirs += sorted(
                  [fulldir(x) for x in listdir if prefix in x]
              )
  
      """
      Enforce selection rules, which check logdirs for certain substrings.
      Makes it easier to look at graphs from particular ablations, if you
      launch many jobs at once with similar names.
      """
      if select is not None:
          logdirs = [
              log for log in logdirs if all(x in log for x in select)
          ]
      if exclude is not None:
          logdirs = [
              log
              for log in logdirs
              if all(not (x in log) for x in exclude)
          ]
  
      # Verify logdirs
      print("Plotting from...\n" + "=" * DIV_LINE_WIDTH + "\n")
      for logdir in logdirs:
          print(logdir)
      print("\n" + "=" * DIV_LINE_WIDTH)
  
      # Make sure the legend is compatible with the logdirs
      assert not (legend) or (
          len(legend) == len(logdirs)
      ), "Must give a legend title for each set of experiments."
  
      # Load data from logdirs
      data = []
      if legend:
          for log, leg in zip(logdirs, legend):
              data += get_datasets(log, leg)
      else:
          for log in logdirs:
              data += get_datasets(log)
      return data
  
file_path: spinningup/spinup/utils/plot.py
imports: import seaborn
  import pandas
  import matplotlib.pyplot
  import json
  import os
  import os.path
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: get_all_datasets(all_logdirs, legend, select, exclude) and returns: data