code: def _git_ls_ignored_cmd(extended_patterns_file, directory_flag):
      """Returns the Git command for listing ignored files.
  
      Contains `ls-files` with options for listing ignored files. Uses
      `--exclude-standard` to apply the standard gitignore rules to the
      result.
  
      If `extended_patterns_file` is specified, includes `-x` args for
      each line in file.
  
      If `directory_flag` is True, includes `--directory` option.
      """
      cmd = [_git_exe.read(), "ls-files", "-ioc", "--exclude-standard"]
      if directory_flag:
          cmd.append("--directory")
      if extended_patterns_file:
          cmd.extend(
              _exclude_args_for_patterns_file(extended_patterns_file)
          )
      return cmd
  
imports: import collections
  import logging
  import re
  import os
  import subprocess
  from guild import config
  from guild import file_util
  from guild import util
  from guild.file_util import FileSelectRule
label_desc: Use image node_id 23 for calling a global function with example usage: _git_ls_ignored_cmd(extended_patterns_file, directory_flag) and returns: cmd