We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Prevent decoding unicode strs to unicode in Py2
Fixes #67 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchtext/data/field.py`
Content:
```
1 from collections import Counter, OrderedDict
2 import six
3 import torch
4 from torch.autograd import Variable
5 
6 from .dataset import Dataset
7 from .pipeline import Pipeline
8 from .utils import get_tokenizer
9 from ..vocab import Vocab
10 
11 
12 class Field(object):
13     """Defines a datatype together with instructions for converting to Tensor.
14 
15     Every dataset consists of one or more types of data. For instance, a text
16     classification dataset contains sentences and their classes, while a
17     machine translation dataset contains paired examples of text in two
18     languages. Each of these types of data is represented by a Field object,
19     which holds a Vocab object that defines the set of possible values for
20     elements of the field and their corresponding numerical representations.
21     The Field object also holds other parameters relating to how a datatype
22     should be numericalized, such as a tokenization method and the kind of
23     Tensor that should be produced.
24 
25     If a Field is shared between two columns in a dataset (e.g., question and
26     answer in a QA dataset), then they will have a shared vocabulary.
27 
28     Attributes:
29         sequential: Whether the datatype represents sequential data. If False,
30             no tokenization is applied. Default: True.
31         use_vocab: Whether to use a Vocab object. If False, the data in this
32             field should already be numerical. Default: True.
33         init_token: A token that will be prepended to every example using this
34             field, or None for no initial token. Default: None.
35         eos_token: A token that will be appended to every example using this
36             field, or None for no end-of-sentence token. Default: None.
37         fix_length: A fixed length that all examples using this field will be
38             padded to, or None for flexible sequence lengths. Default: None.
39         tensor_type: The torch.Tensor class that represents a batch of examples
40             of this kind of data. Default: torch.LongTensor.
41         preprocessing: The Pipeline that will be applied to examples
42             using this field after tokenizing but before numericalizing. Many
43             Datasets replace this attribute with a custom preprocessor.
44             Default: the identity Pipeline.
45         postprocessing: A Pipeline that will be applied to examples using
46             this field after numericalizing but before the numbers are turned
47             into a Tensor. Default: the identity Pipeline.
48         lower: Whether to lowercase the text in this field. Default: False.
49         tokenize: The function used to tokenize strings using this field into
50             sequential examples. Default: str.split.
51         include_lengths: Whether to return a tuple of a padded minibatch and
52             a list containing the lengths of each examples, or just a padded
53             minibatch. Default: False.
54         batch_first: Whether to produce tensors with the batch dimension first.
55             Default: False.
56         pad_token: The string token used as padding. Default: "<pad>".
57     """
58 
59     def __init__(
60             self, sequential=True, use_vocab=True, init_token=None,
61             eos_token=None, fix_length=None, tensor_type=torch.LongTensor,
62             preprocessing=None, postprocessing=None, lower=False,
63             tokenize=(lambda s: s.split()), include_lengths=False,
64             batch_first=False, pad_token="<pad>"):
65         self.sequential = sequential
66         self.use_vocab = use_vocab
67         self.init_token = init_token
68         self.eos_token = eos_token
69         self.fix_length = fix_length
70         self.tensor_type = tensor_type
71         self.preprocessing = (Pipeline() if preprocessing
72                               is None else preprocessing)
73         self.postprocessing = (Pipeline() if postprocessing
74                                is None else postprocessing)
75         self.lower = lower
76         self.tokenize = get_tokenizer(tokenize)
77         self.include_lengths = include_lengths
78         self.batch_first = batch_first
79         self.pad_token = pad_token if self.sequential else None
80 
81     def preprocess(self, x):
82         """Load a single example using this field, tokenizing if necessary.
83 
84         If the input is a Python 2 `str`, it will be converted to Unicode
85         first. If `sequential=True`, it will be tokenized. Then the input
86         will be optionally lowercased and passed to the user-provided
87         `preprocessing` Pipeline."""
88         if six.PY2 and isinstance(x, six.string_types):
89             x = Pipeline(lambda s: unicode(s, encoding='utf-8'))(x)
90         if self.sequential and isinstance(x, six.text_type):
91             x = self.tokenize(x)
92         if self.lower:
93             x = Pipeline(six.text_type.lower)(x)
94         return self.preprocessing(x)
95 
96     def pad(self, minibatch):
97         """Pad a batch of examples using this field.
98 
99         Pads to self.fix_length if provided, otherwise pads to the length of
100         the longest example in the batch. Prepends self.init_token and appends
101         self.eos_token if those attributes are not None. Returns a tuple of the
102         padded list and a list containing lengths of each example if
103         `self.include_lengths` is `True`, else just returns the padded list.
104         """
105         minibatch = list(minibatch)
106         if not self.sequential:
107             return minibatch
108         if self.fix_length is None:
109             max_len = max(len(x) for x in minibatch)
110         else:
111             max_len = self.fix_length + (
112                 self.init_token, self.eos_token).count(None) - 2
113         padded, lengths = [], []
114         for x in minibatch:
115             padded.append(
116                 ([] if self.init_token is None else [self.init_token]) +
117                 list(x[:max_len]) +
118                 ([] if self.eos_token is None else [self.eos_token]) +
119                 [self.pad_token] * max(0, max_len - len(x)))
120             lengths.append(len(padded[-1]) - max(0, max_len - len(x)))
121         if self.include_lengths:
122             return (padded, lengths)
123         return padded
124 
125     def build_vocab(self, *args, **kwargs):
126         """Construct the Vocab object for this field from one or more datasets.
127 
128         Arguments:
129             Positional arguments: Dataset objects or other iterable data
130                 sources from which to construct the Vocab object that
131                 represents the set of possible values for this field. If
132                 a Dataset object is provided, all columns corresponding
133                 to this field are used; individual columns can also be
134                 provided directly.
135             Remaining keyword arguments: Passed to the constructor of Vocab.
136         """
137         counter = Counter()
138         sources = []
139         for arg in args:
140             if isinstance(arg, Dataset):
141                 sources += [getattr(arg, name) for name, field in
142                             arg.fields.items() if field is self]
143             else:
144                 sources.append(arg)
145         for data in sources:
146             for x in data:
147                 if not self.sequential:
148                     x = [x]
149                 counter.update(x)
150         specials = list(OrderedDict.fromkeys(
151             tok for tok in [self.pad_token, self.init_token, self.eos_token]
152             if tok is not None))
153         self.vocab = Vocab(counter, specials=specials, **kwargs)
154 
155     def numericalize(self, arr, device=None, train=True):
156         """Turn a batch of examples that use this field into a Variable.
157 
158         If the field has include_lengths=True, a tensor of lengths will be
159         included in the return value.
160 
161         Arguments:
162             arr: List of tokenized and padded examples, or tuple of a padded
163                 list and a list of lengths if self.include_lengths is True.
164             device: Device to create the Variable's Tensor on. Use -1 for
165                 CPU and None for the currently active GPU device. Default:
166                 None.
167             train: Whether the batch is for a training set. If False, the
168                 Variable will be created with volatile=True. Default: True.
169         """
170         if isinstance(arr, tuple):
171             arr, lengths = arr
172         if self.use_vocab:
173             if self.sequential:
174                 arr = [[self.vocab.stoi[x] for x in ex] for ex in arr]
175             else:
176                 arr = [self.vocab.stoi[x] for x in arr]
177             arr = self.postprocessing(arr, self.vocab, train)
178         else:
179             arr = self.postprocessing(arr, train)
180         arr = self.tensor_type(arr)
181         if self.include_lengths:
182             lengths = torch.LongTensor(lengths)
183         if self.sequential and not self.batch_first:
184             arr.t_()
185         if device == -1:
186             if self.sequential:
187                 arr = arr.contiguous()
188         else:
189             arr = arr.cuda(device)
190             if self.include_lengths:
191                 lengths = lengths.cuda(device)
192         if self.include_lengths:
193             return Variable(arr, volatile=not train), lengths
194         return Variable(arr, volatile=not train)
195
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/torchtext/data/field.py b/torchtext/data/field.py
--- a/torchtext/data/field.py
+++ b/torchtext/data/field.py
@@ -85,7 +85,8 @@
         first. If `sequential=True`, it will be tokenized. Then the input
         will be optionally lowercased and passed to the user-provided
         `preprocessing` Pipeline."""
-        if six.PY2 and isinstance(x, six.string_types):
+        if (six.PY2 and isinstance(x, six.string_types) and not
+                isinstance(x, unicode)):
             x = Pipeline(lambda s: unicode(s, encoding='utf-8'))(x)
         if self.sequential and isinstance(x, six.text_type):
             x = self.tokenize(x)

{"golden_diff": "diff --git a/torchtext/data/field.py b/torchtext/data/field.py\n--- a/torchtext/data/field.py\n+++ b/torchtext/data/field.py\n@@ -85,7 +85,8 @@\n         first. If `sequential=True`, it will be tokenized. Then the input\n         will be optionally lowercased and passed to the user-provided\n         `preprocessing` Pipeline.\"\"\"\n-        if six.PY2 and isinstance(x, six.string_types):\n+        if (six.PY2 and isinstance(x, six.string_types) and not\n+                isinstance(x, unicode)):\n             x = Pipeline(lambda s: unicode(s, encoding='utf-8'))(x)\n         if self.sequential and isinstance(x, six.text_type):\n             x = self.tokenize(x)\n", "issue": "Prevent decoding unicode strs to unicode in Py2\nFixes #67 \n", "before_files": [{"content": "from collections import Counter, OrderedDict\nimport six\nimport torch\nfrom torch.autograd import Variable\n\nfrom .dataset import Dataset\nfrom .pipeline import Pipeline\nfrom .utils import get_tokenizer\nfrom ..vocab import Vocab\n\n\nclass Field(object):\n    \"\"\"Defines a datatype together with instructions for converting to Tensor.\n\n    Every dataset consists of one or more types of data. For instance, a text\n    classification dataset contains sentences and their classes, while a\n    machine translation dataset contains paired examples of text in two\n    languages. Each of these types of data is represented by a Field object,\n    which holds a Vocab object that defines the set of possible values for\n    elements of the field and their corresponding numerical representations.\n    The Field object also holds other parameters relating to how a datatype\n    should be numericalized, such as a tokenization method and the kind of\n    Tensor that should be produced.\n\n    If a Field is shared between two columns in a dataset (e.g., question and\n    answer in a QA dataset), then they will have a shared vocabulary.\n\n    Attributes:\n        sequential: Whether the datatype represents sequential data. If False,\n            no tokenization is applied. Default: True.\n        use_vocab: Whether to use a Vocab object. If False, the data in this\n            field should already be numerical. Default: True.\n        init_token: A token that will be prepended to every example using this\n            field, or None for no initial token. Default: None.\n        eos_token: A token that will be appended to every example using this\n            field, or None for no end-of-sentence token. Default: None.\n        fix_length: A fixed length that all examples using this field will be\n            padded to, or None for flexible sequence lengths. Default: None.\n        tensor_type: The torch.Tensor class that represents a batch of examples\n            of this kind of data. Default: torch.LongTensor.\n        preprocessing: The Pipeline that will be applied to examples\n            using this field after tokenizing but before numericalizing. Many\n            Datasets replace this attribute with a custom preprocessor.\n            Default: the identity Pipeline.\n        postprocessing: A Pipeline that will be applied to examples using\n            this field after numericalizing but before the numbers are turned\n            into a Tensor. Default: the identity Pipeline.\n        lower: Whether to lowercase the text in this field. Default: False.\n        tokenize: The function used to tokenize strings using this field into\n            sequential examples. Default: str.split.\n        include_lengths: Whether to return a tuple of a padded minibatch and\n            a list containing the lengths of each examples, or just a padded\n            minibatch. Default: False.\n        batch_first: Whether to produce tensors with the batch dimension first.\n            Default: False.\n        pad_token: The string token used as padding. Default: \"<pad>\".\n    \"\"\"\n\n    def __init__(\n            self, sequential=True, use_vocab=True, init_token=None,\n            eos_token=None, fix_length=None, tensor_type=torch.LongTensor,\n            preprocessing=None, postprocessing=None, lower=False,\n            tokenize=(lambda s: s.split()), include_lengths=False,\n            batch_first=False, pad_token=\"<pad>\"):\n        self.sequential = sequential\n        self.use_vocab = use_vocab\n        self.init_token = init_token\n        self.eos_token = eos_token\n        self.fix_length = fix_length\n        self.tensor_type = tensor_type\n        self.preprocessing = (Pipeline() if preprocessing\n                              is None else preprocessing)\n        self.postprocessing = (Pipeline() if postprocessing\n                               is None else postprocessing)\n        self.lower = lower\n        self.tokenize = get_tokenizer(tokenize)\n        self.include_lengths = include_lengths\n        self.batch_first = batch_first\n        self.pad_token = pad_token if self.sequential else None\n\n    def preprocess(self, x):\n        \"\"\"Load a single example using this field, tokenizing if necessary.\n\n        If the input is a Python 2 `str`, it will be converted to Unicode\n        first. If `sequential=True`, it will be tokenized. Then the input\n        will be optionally lowercased and passed to the user-provided\n        `preprocessing` Pipeline.\"\"\"\n        if six.PY2 and isinstance(x, six.string_types):\n            x = Pipeline(lambda s: unicode(s, encoding='utf-8'))(x)\n        if self.sequential and isinstance(x, six.text_type):\n            x = self.tokenize(x)\n        if self.lower:\n            x = Pipeline(six.text_type.lower)(x)\n        return self.preprocessing(x)\n\n    def pad(self, minibatch):\n        \"\"\"Pad a batch of examples using this field.\n\n        Pads to self.fix_length if provided, otherwise pads to the length of\n        the longest example in the batch. Prepends self.init_token and appends\n        self.eos_token if those attributes are not None. Returns a tuple of the\n        padded list and a list containing lengths of each example if\n        `self.include_lengths` is `True`, else just returns the padded list.\n        \"\"\"\n        minibatch = list(minibatch)\n        if not self.sequential:\n            return minibatch\n        if self.fix_length is None:\n            max_len = max(len(x) for x in minibatch)\n        else:\n            max_len = self.fix_length + (\n                self.init_token, self.eos_token).count(None) - 2\n        padded, lengths = [], []\n        for x in minibatch:\n            padded.append(\n                ([] if self.init_token is None else [self.init_token]) +\n                list(x[:max_len]) +\n                ([] if self.eos_token is None else [self.eos_token]) +\n                [self.pad_token] * max(0, max_len - len(x)))\n            lengths.append(len(padded[-1]) - max(0, max_len - len(x)))\n        if self.include_lengths:\n            return (padded, lengths)\n        return padded\n\n    def build_vocab(self, *args, **kwargs):\n        \"\"\"Construct the Vocab object for this field from one or more datasets.\n\n        Arguments:\n            Positional arguments: Dataset objects or other iterable data\n                sources from which to construct the Vocab object that\n                represents the set of possible values for this field. If\n                a Dataset object is provided, all columns corresponding\n                to this field are used; individual columns can also be\n                provided directly.\n            Remaining keyword arguments: Passed to the constructor of Vocab.\n        \"\"\"\n        counter = Counter()\n        sources = []\n        for arg in args:\n            if isinstance(arg, Dataset):\n                sources += [getattr(arg, name) for name, field in\n                            arg.fields.items() if field is self]\n            else:\n                sources.append(arg)\n        for data in sources:\n            for x in data:\n                if not self.sequential:\n                    x = [x]\n                counter.update(x)\n        specials = list(OrderedDict.fromkeys(\n            tok for tok in [self.pad_token, self.init_token, self.eos_token]\n            if tok is not None))\n        self.vocab = Vocab(counter, specials=specials, **kwargs)\n\n    def numericalize(self, arr, device=None, train=True):\n        \"\"\"Turn a batch of examples that use this field into a Variable.\n\n        If the field has include_lengths=True, a tensor of lengths will be\n        included in the return value.\n\n        Arguments:\n            arr: List of tokenized and padded examples, or tuple of a padded\n                list and a list of lengths if self.include_lengths is True.\n            device: Device to create the Variable's Tensor on. Use -1 for\n                CPU and None for the currently active GPU device. Default:\n                None.\n            train: Whether the batch is for a training set. If False, the\n                Variable will be created with volatile=True. Default: True.\n        \"\"\"\n        if isinstance(arr, tuple):\n            arr, lengths = arr\n        if self.use_vocab:\n            if self.sequential:\n                arr = [[self.vocab.stoi[x] for x in ex] for ex in arr]\n            else:\n                arr = [self.vocab.stoi[x] for x in arr]\n            arr = self.postprocessing(arr, self.vocab, train)\n        else:\n            arr = self.postprocessing(arr, train)\n        arr = self.tensor_type(arr)\n        if self.include_lengths:\n            lengths = torch.LongTensor(lengths)\n        if self.sequential and not self.batch_first:\n            arr.t_()\n        if device == -1:\n            if self.sequential:\n                arr = arr.contiguous()\n        else:\n            arr = arr.cuda(device)\n            if self.include_lengths:\n                lengths = lengths.cuda(device)\n        if self.include_lengths:\n            return Variable(arr, volatile=not train), lengths\n        return Variable(arr, volatile=not train)\n", "path": "torchtext/data/field.py"}], "after_files": [{"content": "from collections import Counter, OrderedDict\nimport six\nimport torch\nfrom torch.autograd import Variable\n\nfrom .dataset import Dataset\nfrom .pipeline import Pipeline\nfrom .utils import get_tokenizer\nfrom ..vocab import Vocab\n\n\nclass Field(object):\n    \"\"\"Defines a datatype together with instructions for converting to Tensor.\n\n    Every dataset consists of one or more types of data. For instance, a text\n    classification dataset contains sentences and their classes, while a\n    machine translation dataset contains paired examples of text in two\n    languages. Each of these types of data is represented by a Field object,\n    which holds a Vocab object that defines the set of possible values for\n    elements of the field and their corresponding numerical representations.\n    The Field object also holds other parameters relating to how a datatype\n    should be numericalized, such as a tokenization method and the kind of\n    Tensor that should be produced.\n\n    If a Field is shared between two columns in a dataset (e.g., question and\n    answer in a QA dataset), then they will have a shared vocabulary.\n\n    Attributes:\n        sequential: Whether the datatype represents sequential data. If False,\n            no tokenization is applied. Default: True.\n        use_vocab: Whether to use a Vocab object. If False, the data in this\n            field should already be numerical. Default: True.\n        init_token: A token that will be prepended to every example using this\n            field, or None for no initial token. Default: None.\n        eos_token: A token that will be appended to every example using this\n            field, or None for no end-of-sentence token. Default: None.\n        fix_length: A fixed length that all examples using this field will be\n            padded to, or None for flexible sequence lengths. Default: None.\n        tensor_type: The torch.Tensor class that represents a batch of examples\n            of this kind of data. Default: torch.LongTensor.\n        preprocessing: The Pipeline that will be applied to examples\n            using this field after tokenizing but before numericalizing. Many\n            Datasets replace this attribute with a custom preprocessor.\n            Default: the identity Pipeline.\n        postprocessing: A Pipeline that will be applied to examples using\n            this field after numericalizing but before the numbers are turned\n            into a Tensor. Default: the identity Pipeline.\n        lower: Whether to lowercase the text in this field. Default: False.\n        tokenize: The function used to tokenize strings using this field into\n            sequential examples. Default: str.split.\n        include_lengths: Whether to return a tuple of a padded minibatch and\n            a list containing the lengths of each examples, or just a padded\n            minibatch. Default: False.\n        batch_first: Whether to produce tensors with the batch dimension first.\n            Default: False.\n        pad_token: The string token used as padding. Default: \"<pad>\".\n    \"\"\"\n\n    def __init__(\n            self, sequential=True, use_vocab=True, init_token=None,\n            eos_token=None, fix_length=None, tensor_type=torch.LongTensor,\n            preprocessing=None, postprocessing=None, lower=False,\n            tokenize=(lambda s: s.split()), include_lengths=False,\n            batch_first=False, pad_token=\"<pad>\"):\n        self.sequential = sequential\n        self.use_vocab = use_vocab\n        self.init_token = init_token\n        self.eos_token = eos_token\n        self.fix_length = fix_length\n        self.tensor_type = tensor_type\n        self.preprocessing = (Pipeline() if preprocessing\n                              is None else preprocessing)\n        self.postprocessing = (Pipeline() if postprocessing\n                               is None else postprocessing)\n        self.lower = lower\n        self.tokenize = get_tokenizer(tokenize)\n        self.include_lengths = include_lengths\n        self.batch_first = batch_first\n        self.pad_token = pad_token if self.sequential else None\n\n    def preprocess(self, x):\n        \"\"\"Load a single example using this field, tokenizing if necessary.\n\n        If the input is a Python 2 `str`, it will be converted to Unicode\n        first. If `sequential=True`, it will be tokenized. Then the input\n        will be optionally lowercased and passed to the user-provided\n        `preprocessing` Pipeline.\"\"\"\n        if (six.PY2 and isinstance(x, six.string_types) and not\n                isinstance(x, unicode)):\n            x = Pipeline(lambda s: unicode(s, encoding='utf-8'))(x)\n        if self.sequential and isinstance(x, six.text_type):\n            x = self.tokenize(x)\n        if self.lower:\n            x = Pipeline(six.text_type.lower)(x)\n        return self.preprocessing(x)\n\n    def pad(self, minibatch):\n        \"\"\"Pad a batch of examples using this field.\n\n        Pads to self.fix_length if provided, otherwise pads to the length of\n        the longest example in the batch. Prepends self.init_token and appends\n        self.eos_token if those attributes are not None. Returns a tuple of the\n        padded list and a list containing lengths of each example if\n        `self.include_lengths` is `True`, else just returns the padded list.\n        \"\"\"\n        minibatch = list(minibatch)\n        if not self.sequential:\n            return minibatch\n        if self.fix_length is None:\n            max_len = max(len(x) for x in minibatch)\n        else:\n            max_len = self.fix_length + (\n                self.init_token, self.eos_token).count(None) - 2\n        padded, lengths = [], []\n        for x in minibatch:\n            padded.append(\n                ([] if self.init_token is None else [self.init_token]) +\n                list(x[:max_len]) +\n                ([] if self.eos_token is None else [self.eos_token]) +\n                [self.pad_token] * max(0, max_len - len(x)))\n            lengths.append(len(padded[-1]) - max(0, max_len - len(x)))\n        if self.include_lengths:\n            return (padded, lengths)\n        return padded\n\n    def build_vocab(self, *args, **kwargs):\n        \"\"\"Construct the Vocab object for this field from one or more datasets.\n\n        Arguments:\n            Positional arguments: Dataset objects or other iterable data\n                sources from which to construct the Vocab object that\n                represents the set of possible values for this field. If\n                a Dataset object is provided, all columns corresponding\n                to this field are used; individual columns can also be\n                provided directly.\n            Remaining keyword arguments: Passed to the constructor of Vocab.\n        \"\"\"\n        counter = Counter()\n        sources = []\n        for arg in args:\n            if isinstance(arg, Dataset):\n                sources += [getattr(arg, name) for name, field in\n                            arg.fields.items() if field is self]\n            else:\n                sources.append(arg)\n        for data in sources:\n            for x in data:\n                if not self.sequential:\n                    x = [x]\n                counter.update(x)\n        specials = list(OrderedDict.fromkeys(\n            tok for tok in [self.pad_token, self.init_token, self.eos_token]\n            if tok is not None))\n        self.vocab = Vocab(counter, specials=specials, **kwargs)\n\n    def numericalize(self, arr, device=None, train=True):\n        \"\"\"Turn a batch of examples that use this field into a Variable.\n\n        If the field has include_lengths=True, a tensor of lengths will be\n        included in the return value.\n\n        Arguments:\n            arr: List of tokenized and padded examples, or tuple of a padded\n                list and a list of lengths if self.include_lengths is True.\n            device: Device to create the Variable's Tensor on. Use -1 for\n                CPU and None for the currently active GPU device. Default:\n                None.\n            train: Whether the batch is for a training set. If False, the\n                Variable will be created with volatile=True. Default: True.\n        \"\"\"\n        if isinstance(arr, tuple):\n            arr, lengths = arr\n        if self.use_vocab:\n            if self.sequential:\n                arr = [[self.vocab.stoi[x] for x in ex] for ex in arr]\n            else:\n                arr = [self.vocab.stoi[x] for x in arr]\n            arr = self.postprocessing(arr, self.vocab, train)\n        else:\n            arr = self.postprocessing(arr, train)\n        arr = self.tensor_type(arr)\n        if self.include_lengths:\n            lengths = torch.LongTensor(lengths)\n        if self.sequential and not self.batch_first:\n            arr.t_()\n        if device == -1:\n            if self.sequential:\n                arr = arr.contiguous()\n        else:\n            arr = arr.cuda(device)\n            if self.include_lengths:\n                lengths = lengths.cuda(device)\n        if self.include_lengths:\n            return Variable(arr, volatile=not train), lengths\n        return Variable(arr, volatile=not train)\n", "path": "torchtext/data/field.py"}]}