code: def from_file(cls, path, fs, name):
      assert fs.isabs(path)
      dirname = fs.normpath(fs.dirname(path))
      with fs.open(path, encoding="utf-8") as fobj:
          path_spec_lines = [
              PatternInfo(line, f"{name}:{line_no + 1}:{line}")
              for line_no, line in enumerate(
                  map(str.strip, fobj.readlines())
              )
              if line and not (line.strip().startswith("#"))
          ]
  
      return cls(path_spec_lines, dirname, fs.sep)
  
imports: import os
  import re
  from collections import namedtuple
  from itertools import chain, groupby, takewhile
  from typing import TYPE_CHECKING, List, Optional
  from pathspec.patterns import GitWildMatchPattern
  from pathspec.util import normalize_file
  from pygtrie import Trie
  from dvc.fs import Schemes, localfs
  from dvc.log import logger
  from dvc.pathspec_math import PatternInfo, merge_patterns
label_desc: Use image node_id 2 for calling the DvcIgnorePatterns obj's underlying member method code with example usage: obj.from_file(cls, path, fs, name) and returns: cls