input: Write a function to parse the given URL and return the protocol, domain name, and path using Python. The function should return a dictionary with keys 'protocol', 'domain_name', and 'path'. If the URL is empty or invalid, the function should return an empty dictionary.
  
  assert parse_url('https://www.example.com/path/to/file') == {'protocol': 'https', 'domain_name': 'www.example.com', 'path': '/path/to/file'}
  assert parse_url('http://example.com') == {'protocol': 'http', 'domain_name': 'example.com', 'path': '/'}
  assert parse_url('') == {}
  assert parse_url('invalid_url') == {}
  assert parse_url('ftp://ftp.example.com/path') == {'protocol': 'ftp', 'domain_name': 'ftp.example.com', 'path': '/path'}
output: def parse_url(url):
      if not url:
          return {}
      try:
          parsed_url = urlparse(url)
          if not parsed_url.scheme or not parsed_url.netloc:
              return {}
          return {
              'protocol': parsed_url.scheme,
              'domain_name': parsed_url.netloc,
              'path': parsed_url.path if parsed_url.path else '/'
          }
      except:
          return {}