code: def from_file(cls, path, format='infer'):
          
          format = _infer_format(path, format=format)
          origin = os.path.abspath(os.path.dirname(path))
  
          with open(path) as f:
              data = f.read()
          if format == 'json':
              obj = json.loads(data)
          else:
              obj = yaml.safe_load(data)
          return cls.from_dict(obj, _origin=origin)
docs: Create an instance from a json or yaml file.
  
          Parameters
          ----------
          path : str
              The path to the file to load.
          format : {'infer', 'json', 'yaml'}, optional
              The file format. By default the format is inferred from the file
              extension.