code: def import_scotus_files(max_docs=2000):
      scotus_url = "https://www.courtlistener.com/api/bulk-data/opinions/scotus.tar.gz"
      scotus_dir = "scotusdata"
      index_name = "supremecourt"
  
      if not os.path.exists(scotus_dir):
          os.makedirs(scotus_dir, exist_ok=True)
          logger.info(">>> Downloading supreme court case data")
          ftpstream = urllib.request.urlopen(scotus_url)
          thetarfile = tarfile.open(fileobj=ftpstream, mode="r|gz")
          thetarfile.extractall(path=scotus_dir)
          logger.info(">>> Download completed ")
  
      logger.info(
          ">> Creating %s index using %s documents",
          index_name,
          str(max_docs),
      )
      scotus_files = os.listdir(scotus_dir)
  
      es = Elasticsearch([{"host": "localhost", "port": 9200}])
  
      es.indices.create(
          index=index_name, body=index_settings, ignore=400
      )
  
      i = 0
      for file_path in scotus_files:
          with open("scotusdata/" + file_path) as json_file:
              scotus_case = json.load(json_file)
              case = {
                  "author": scotus_case["author"],
                  "casebody": scotus_case["plain_text"],
              }
              if scotus_case["plain_text"] != "":
                  try:
                      index_status = es.index(
                          index=index_name,
                          id=scotus_case["id"],
                          body=case,
                      )
                  except Exception as e:
                      logger.info(
                          "An error has occurred while creating index "
                          + str(e)
                      )
                      break
                  i += 1
          if i > max_docs:
              break
  
      logger.info(">> Index creation complete.")
  
file_path: neuralqa/neuralqa/utils/data_utils.py
imports: from elasticsearch import Elasticsearch
  import os
  import zipfile
  import shutil
  import urllib.request
  import logging
  import lzma
  import json
  import tarfile
  import hashlib
label_desc: Use image node_id 2 for calling a global function with example usage: import_scotus_files(max_docs) without return types