How iterate over BucketIterator instance when the data parameter of BucketIterator constructor is Dataset with one customizable Example instance?

username: ricky
cooked: <p>When try iterate over bucket iterator with customizable Dataset, it occurs the following error:</p>
<pre><code class="lang-auto">/usr/local/lib/python3.6/dist-packages/torchtext/data/iterator.py in __iter__(self)
    160                     else:
    161                         minibatch.sort(key=self.sort_key, reverse=True)
--&gt; 162                 yield Batch(minibatch, self.dataset, self.device)
    163             if not self.repeat:
    164                 return

/usr/local/lib/python3.6/dist-packages/torchtext/data/batch.py in __init__(self, data, dataset, device)
     26             self.dataset = dataset
     27             self.fields = dataset.fields.keys()  # copy field names
---&gt; 28             self.input_fields = [k for k, v in dataset.fields.items() if
     29                                  v is not None and not v.is_target]
     30             self.target_fields = [k for k, v in dataset.fields.items() if

/usr/local/lib/python3.6/dist-packages/torchtext/data/batch.py in &lt;listcomp&gt;(.0)
     27             self.fields = dataset.fields.keys()  # copy field names
     28             self.input_fields = [k for k, v in dataset.fields.items() if
---&gt; 29                                  v is not None and not v.is_target]
     30             self.target_fields = [k for k, v in dataset.fields.items() if
     31                                   v is not None and v.is_target]

AttributeError: 'tuple' object has no attribute 'is_target'
</code></pre>
<p>my source-code is structured as follows:</p>
<p><strong>Define the fields</strong></p>
<pre><code class="lang-auto">    TEXT = data.Field(
        sequential=True,
        tokenize = 'spacy',
        #batch_first = True,
    ) 
    LABEL = data.LabelField()
</code></pre>
<p><strong>Get Vocabulary</strong></p>
<pre><code class="lang-auto">TEXT.build_vocab(

    train,

    max_size=25000,

    #vectors = "glove.6B.100d",

    vectors = vectors,

    #unk_init = torch.Tensor.normal_

    #min_freq=50,

)

LABEL.build_vocab(

    train

)
</code></pre>
<p><strong>Creating Example and Dataset instances</strong></p>
<pre><code class="lang-auto">fields={"name": ("name", TEXT), "component": ("component", LABEL)}
    
    examples= []
    
    example = Example.fromdict({"name": "exmaple", "component": "Undefined"}, {"name": ("name", TEXT), "component": ("component", LABEL)})

    examples.append(example)

    instance = Dataset(examples=[example], fields=fields)
</code></pre>
<p><strong>Creating bucket iterator instance</strong></p>
<p>BATCH_SIZE = 64</p>
<pre><code class="lang-auto">train_iterator,  instance_iterator = data.BucketIterator.splits(
    (train, instance), 
    sort_key = lambda x: x.name,
    sort = True,
    batch_size = BATCH_SIZE, 
    device = device)
</code></pre>
<p><strong>Iterate over bucket iterator</strong></p>
<pre><code class="lang-auto">    for batch in instance_iterator:
      print(batch.name)
</code></pre>

username: muhammadfhadli1453
cooked: <p>Have you got the solution? I got similar problem here. When I try to print batch.name. The error says<br>
<code>AttributeError: 'BucketIterator' object has no attribute 'name'</code></p>